3.5. Operators

The MDX language, similar to other query languages such as SQL or programming languages, has several operators. An operator is a function that is used to perform a specific action and takes arguments. MDX has several types of operators. Similar to other languages, MDX contains the arithmetic operators, logical operators, and special MDX operators.

3.5.1. Arithmetic Operators

Regular arithmetic operators such as +, −, *, and / are part of the MDX arithmetic operators. Just as with programming languages, these operators can be applied between two numbers. The + and − operators can also be used as unary operators for numbers. Unary operator means the operator can be used with a single operand (single number) in MDX expressions such as + 100 or −100.

3.5.2. Set Operators

The +, −, and * operators, in addition to being arithmetic operators, are also used to perform operations on the MDX Sets. The + operator is used to union two Sets, the − operator is used to evaluate the difference of two Sets, and the * operator is used find the cross product of two sets. Cross product of two sets results in all possible combinations of the tuples in each set and helps in retrieving data in a matrix format. For example if you have the two sets {Male, Female} and {2003, 2004, 2005} then the cross product of the two sets represented as {Male, Female} * {2003, 2004, 2005} is {(Male,2003), (Male,2004), (Male,2005),(Female,2003),(Female,2004),(Female,2005)}. The following examples show ...

Get Professional SQL Server™ Analysis Services 2005 with MDX now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.