Skip to main content

Logical Expressions (MDX)

This section describes how to create and use logical expressions in InterSystems MDX.

Details and Uses

MDX does not include a logical data type. However, it provides the FILTER function and the IIF function, both of which take an argument that is treated as true or false. In these contexts, InterSystems MDX interprets numeric and string values as true or false, as follows:

In the same contexts, you can combine true and false values by using the following standard tools:

  • Logical comparison operators: > (greater than), >= (greater than or equal to), = (equal to), < (less than), and <= (less than or equal to). For example, the following expression returns true or false, depending on the value of MEASURES.[%COUNT]:

    MEASURES.[%COUNT]>1100
    

    For another example, the following expression returns true or false, depending on the name of the current member:

    colord.CURRENTMEMBER.PROPERTIES("Name")="Red"
    

    When a numeric expression is compared to null, the null value is treated as 0.

  • The AND operator, the OR operator, and parentheses to control precedence. For example, the following expression returns true or false, depending on the value of MEASURES.[%COUNT]:

    (MEASURES.[%COUNT]>1100) AND (MEASURES.[%COUNT]<1500)
    

When you compare scalar values of different types, the system compares them as follows:

If Then
Both expressions are numeric Perform a numeric comparison
Both expressions are strings Perform a string comparison
One expression is numeric and the other is a string The numeric expression is less than the string expression

You cannot use member expressions in a logical comparison expression. For example, the following is not a valid logical expression:

homed.CURRENTMEMBER = homed.h1.city.magnolia

Instead, you should use the Name property or some other suitable property, all of which are strings. For example, the following is a valid logical expression:

homed.CURRENTMEMBER.Properties("Name") = "magnolia"

See the reference section Intrinsic Properties for intrinsic properties that you can use.

Also see the section Measure Search Expressions.

FeedbackOpens in a new tab