Skip to main content

Details for Source Expressions

Details for Source Expressions

As noted in the previous section, you can specify either a source value or a source expression to use as the basis of a dimension or level (or property or measure). You can create source expressions as follows:

  • You can refer to a property in the source class. To do so, use the syntax %source.PropertyName, where PropertyName is the name of the property. When it builds the cube, the system parses this expression and looks up the SqlFieldName of the given property.

  • You can use dot syntax to refer to properties of properties.

  • You can refer to an object-valued property. When you do so, the numeric ID of the object is used as the source value.

  • You can use the variable %cube to refer to the cube class; this is useful if you have defined utility methods in the cube class that you want to use within source expressions.

  • You can refer to the value of an <expression> element. To do so, use the following syntax:

    %expression.expressionName
    

    For information on expressions, see Advanced Modeling for InterSystems Business Intelligence

  • You can use the utility methods ToUpper(), ToLower(), and Log() as in the following example:

    ..ToUpper(%source.HomeCity.Name)
    

    The system can use these methods in this way because the fact table class inherits from %DeepSee.CubeFunctionSetOpens in a new tab, which defines them. For details on these methods, see the class reference for that class.

  • You can use the %Lookup() method of %DeepSee.CubeDefinitionOpens in a new tab to invoke a term list. See the subsection Using a Term List.

  • You can use the %Rule() method of %DeepSee.CubeDefinitionOpens in a new tab to invoke a production business rule. See the subsection Using a Production Business Rule.

Note:

You cannot use a source expression if the cube is based on a data connector.

Also, if a level is based on a source expression (rather than a source property) and if the members have purely numeric names, InterSystems recommends that you also modify the cube in Studio and add castAsNumeric="true" to that level definition. This option causes the system to treat the members as numbers when searching for a replacement for a member that does not exist, when a query that uses an MDX range expression (a specific kind of set expression).

Using a Term List

Term lists provide a way to customize an InterSystems IRIS Business Intelligence model without programming. A term list is a simple (but extendable) list of key and value pairs. (See Defining Term Lists.)

You can invoke a term list within a source expression. To do so, use the %Lookup() method of %DeepSee.CubeDefinitionOpens in a new tab. This method has the following signature:

%Lookup(term_list_name, lookup_value,default,alternative_field)

Where the arguments are strings, and their values are as follows:

  • term_list_name evaluates to the name of a term list.

  • lookup_value evaluates to the string to look up in the term list.

  • default, which is optional, evaluates to the value to return if lookup_value is not found in the term list.

  • alternative_field, which is optional, is the name of the field to return. The default is "value".

    This argument is not case-sensitive.

This function examines the given term list, finds the term whose "key" field equals the string given by lookup_value and then returns the value contained in the field identified by alternative_field.

All term lists have at least two fields: "key" and "value". You can add additional fields. For information, see Defining Term Lists.

Note:

Because your cube definition class inherits from %DeepSee.CubeDefinitionOpens in a new tab, which defines the %Lookup() method, you can use a source expression like the following:

%cube.%Lookup(term_list_name,lookup_value,default,alternative_field)

For example, suppose that you have the following term list, called LocalTeams:

The Term List Manager showing a term list, where terms have a Key that is a city and a Value that is a baseball team name.

You could add a property to the City level in HoleFoods as follows:

<property name="Team" sourceExpression='%cube.%Lookup("LocalTeams",%source.Outlet.City,"No Team")'/>

Using a Production Business Rule

Business rules allow nontechnical users to change the behavior of business processes in productions. You can also use them in source expressions in cubes. (For details on production business rules, see Developing Business Rules.)

To access a production business rule within a source expression, use the %Rule() method of %DeepSee.CubeDefinitionOpens in a new tab. This method has the following signature:

%Rule(rule_name)

Where rule_name is the name of a production business rule.

When this function is evaluated (for a given source record) during a cube build, the system passes to it an instance of the cube source class as the context object. The system uses this object, evaluates the rule, and then accesses the value returned by the rule.

Note:

Because your cube definition class inherits from %DeepSee.CubeDefinitionOpens in a new tab, which defines the %Rule() method, you can use a source expression like the following:

%cube.%Rule(rule_name)
FeedbackOpens in a new tab