<measure>
Details
The <measure> element has the following attributes:
Attribute | Purpose |
---|---|
name, displayName, description, disabled | See Common Attributes in a Cube. |
sourceProperty, sourceExpression | Specify one of these attributes in almost the same way that you would specify Property or Expression in the Architect; see Specifying the Source Values for a Dimension or Level and Details for Source Expressions. Notes:
|
type | (Optional) Specifies the data type for the measure. Most measures are numeric, which is the default. See Specifying the Measure Type. |
iKnowSource, iKnowDomain, iKnowDictionaries, iKnowParameters | (Optional) See Using Text Analytics in Cubes. |
aggregate | (Optional) Specifies how to aggregate values for this measure, whenever combining multiple records. If you specify this, use one of the following values:
|
hidden | (Optional) If hidden="true" then the measure is defined and can be used in queries, but is not listed as an available measure in the Analyzer. This lets you define measures that serve as intermediate calculations. |
scale | (Optional) Specifies the number of decimal places to keep. By default, scale is 0, and the system rounds each measure value to a whole number before writing it to the fact table. |
linkClass, linkProperty | (Optional) See Linking to Another Table. |
searchable | (Optional) If searchable="true" then the system displays this measure as an option in advanced filters, where you can create filter expressions that refer to the measure value (typically to compare the measure value to a constant).
For a searchable measure, the system adds an additional index, if appropriate, to support these expressions. See Measure Search Expressions. A searchable measure cannot include square brackets or commas ([],) in its name. Note that it may be possible to use a measure as a searchable measure in a manual MDX query even if it is not marked as searchable="true". In all cases, the measure is also available for use in the same way as any other measure. |
factName |
(Optional) Name, in the generated fact table, for the column that corresponds to this measure. If this attribute is null, the system generates a name. This option does not apply to NLP measures. Be sure not to use an SQL reserved word. For a list of the SQL reserved words, see Reserved Words. 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. |
factNumber | Internal ID assigned to this measure. Required if namedFactNums is "true" for the cube. |
factSelectivity | (Optional, not used by the system)Value to override the generated selectivity of the property in the fact table class. Business Intelligence queries do not use this parameter. This option is intended for cases where SQL is used directly against the generated fact table and the generated selectivity needs to be overridden.
Specify a positive value less than or equal to 1. For details, see SetFieldSelectivity() in %SYSTEM.SQLOpens in a new tab. |
formatString | (Optional) Controls how the values are displayed. See formatString Details. |
units | (Optional) Indicates the units in which the measure value is expressed. Currently this attribute is provided only for general information. |
listingFilterOperator and listingFilterValue | (Optional) These attributes specify an optional additional filter that is applied when a user selects this measure in a pivot table and then displays a listing. For details, see Specifying Additional Filtering for Listings, in Defining Measures. |
Example
For example:
<measure name="Test Score" sourceProperty="TestScore" aggregate="SUM"/>
<measure name="Avg Test Score" sourceProperty="TestScore" aggregate="AVG"/>
<measure name="Allergy Count"
sourceExpression="##class(Cubes.StudyPatients).GetAllergyCount(%source.%ID)"/>
Notice that the Allergy Count measure uses a utility method that is defined within the cube class.
%COUNT Measure
The system includes a predefined measure named %COUNT, which returns the number of facts in a query.
Measures Dimension
The system automatically creates the Measures dimension, and places all measures into it.
formatString Details
The formatString attribute is a pieced string as follows:
Format^Color
-
For the Format piece, specify a string that consists of one to four subpieces as follows:
positive_format;negative_format;zero_format;missing_format;
Where positive_format controls how a positive value is displayed, negative_format controls how a negative value is displayed, zero_format controls how zero is displayed, and missing_format controls how a missing value is displayed.
For details, see Specifying a Format String.
-
For the Color piece, specify a string that consists of one to four subpieces as follows:
positive_color;negative_color;zero_color;missing_color;
Where positive_color controls the color for a positive value, negative_color controls the color for a negative value, zero_color controls the color for zero, and missing_color controls the color for a missing value.
For each of these, specify a CSS color nameOpens in a new tab or a hex color codeOpens in a new tab.
For date measures, use the following variation:
%date%^Color
Where Color is as given above. The %date% piece formats the date according to the default date format for the current process.