Defining Measures
This page describes how to define measures in a Business Intelligence cube.
The system automatically creates a measure whose default name is Count. To override this default name, specify the Count measure caption option for the cube; see Specifying Cube Options.
Also see Accessing the Samples Shown in This Book.
Adding a Measure
To add a measure, drag a class property from the Class Viewer and drop it onto the Measures label in the Model Viewer. Then make changes if needed in the Details Area.
Or do the following:
-
Click Add Element.
The system displays a dialog box.
-
For Enter New Item Name, type a measure name.
See Names for Model Elements.
-
Click Measure.
-
Click OK.
-
Select the measure in the Model Viewer.
-
Specify the following options, at a minimum:
Specifying the Measure Type
The Type option specifies the kind of data the measure expects in the source data, as well as the type used in the generated fact table, as follows:
Measure Type |
Expected Type of Source Data |
Type Used by Measure |
Measure Details |
number (this is the default) |
Numeric data |
%DoubleOpens in a new tab |
Numeric value. Default aggregation is SUM. |
integer |
Numeric data (any fractional values are removed by truncation) |
%IntegerOpens in a new tab |
Integer value. Default aggregation is SUM. |
age |
Date/time data in $Horolog format |
%IntegerOpens in a new tab |
Age value in days. Can be used only with AVG (default), MIN, and MAX aggregations. Age measures are not generally recommended, unless you perform nightly full cube rebuilds or nightly selective builds of those age measures. |
date |
Date/time data in $Horolog format |
%DeepSee.Datatype.dateTimeOpens in a new tab |
Date value (in $Horolog format, with seconds removed). Can be used only with AVG, MIN, and MAX (default) aggregations. |
boolean |
0 or 1 |
%BooleanOpens in a new tab |
Boolean value that can be aggregated. Default aggregation is COUNT. |
string |
Any |
%StringOpens in a new tab |
String values to be stored in the fact table; these are not indexed. Can be used only with COUNT. This measure cannot be dragged and dropped in the Analyzer. |
iKnow* |
Text values |
%GlobalCharacterStreamOpens in a new tab or %StringOpens in a new tab, depending on the selected source |
Text values to be processed and indexed using the NLP Smart Indexing API. This measure cannot be dragged and dropped in the Analyzer. |
*For information on the iKnow type, see the Advanced Modeling for InterSystems Business Intelligence.
Specifying How to Aggregate a Measure
The Aggregate option specifies how to aggregate values for this measure, whenever combining multiple records. If you specify this, use one of the following values:
-
SUM (the default) — Adds the values in the set.
-
COUNT — Counts the records for which the source data has a non-null (and nonzero) value.
-
MAX — Uses the largest value in the set.
-
MIN — Uses the smallest value in the set.
-
AVG — Calculates the average value for the set.
For a boolean or a string measure, select COUNT.
Specifying a Searchable Measure
You can specify that a measure is searchable; if so, you can filter records used in a pivot table by the value of that measure.
To specify a measure as searchable, select the Searchable check box in the Details Area.
Note:
A searchable measure cannot include square brackets or commas ([],) in its name.
Changing the Order of Measures in the Cube
To change the order of measures in the cube:
-
Click Reorder.
The system displays a dialog box.
-
Click Measures.
-
Optionally click Alphabetize to alphabetize them.
This affects the list immediately. You can then reorganize the list further if needed. Also, when you add measures, they are not automatically alphabetized.
-
Click the name of a measure and then click the up or down arrow as needed.
-
Repeat as needed for other measures.
-
Click OK.
The order of the measures in the cube affects how they are displayed in the Analyzer. It does not have any other effect. Some customers choose to alphabetize their measures for convenience; others put more-often used measures at the top of the list.
Specifying the Field Names in the Fact Table
When you compile a cube class, the system generates a fact table class and some related classes. When you build a cube, the system populates these tables, which are described in Details for the Fact and Dimension Tables.
By default, the system generates the names of the columns in the fact table, but you can specify the column names to use instead. To do so, specify a value for the Field name in fact table option for each measure. This option is not available for NLP measures. Take care to use unique names.
Important:
For Field name in fact table, be sure not to use an SQL reserved word. For a list of the SQL reserved words, see Reserved Words in the InterSystems SQL Reference. The name must start with either a letter or a percent sign (%). If the first character is %, the second character must be Z or z. For more details on restrictions, see Class Members. Also, do not use fact or listing, in any combination of lowercase and uppercase characters.
Specifying Additional Filtering for Listings
By default, when a user displays a detail listing, the system displays one row for each source record that is used in the current context (that is, the context in which the listing was requested). For a given measure, you can specify an additional filter for the system to use when displaying the detail listing. For example, consider the Avg Test Score measure in the Patients sample. This measure is based on the TestScore property, which is null for some patients. You could redefine this measure to filter out those patients, when the user starts on the Avg Test Score measure and then displays a listing.
If you need such a filter, you include it as part of the measure definition. In most cases, the filter has the following form:
measure_value operator comparison_value
This filter is added to the detail listing query and removes any records that do not meet the filter criteria.
The other form of listing filter is MAX/MIN. If you use such a listing filter, the detail listing shows only the records that have the maximum (or minimum) value of the measure. The measure must use the same kind of aggregation as does the listing filter (if a listing filter is included).
To specify an additional filter for listings, for a specific measure:
-
Select the measure in the Model Viewer.
If you intend to use MAX for the listing filter, select a measure that is defined with Aggregate as MAX.
Similarly, if you intend to use MIN, select a measure that is defined with Aggregate as MIN.
-
In the section Measure-Specific Listing Filter (in the Details Area), specify the following values:
When you use this option, the Architect automatically enables the Searchable check box, because this measure must be searchable.
Example
Suppose that we modify the Avg Test Score measure in the Patients cube, and we specify Operator as <> and Value as "". That is, we want to filter out the patients that have null test scores. Then consider the following pivot table:
If we click the Patient Count cell (or the Avg Age cell) in the CHD row and then display a detail listing, we see something like this:
But if we click the Avg Test Score cell in the pivot table and then display a detail listing, we see fewer records, like this: