Professional Microsoft® SQL Server® Analysis Services 2008 with MDX
by Sivakumar Harinath, Matt Carroll, Sethu Meenakshisundaram, Robert Zare, Denny Guang-Yeu Lee
3.5. Operators
The MDX language, similar to other query languages such as SQL or other general-purpose programming languages, has several operators. An operator is a function that is used to perform a specific action, takes arguments, and returns a result. MDX has several types of operators including arithmetic operators, logical operators, and special MDX operators.
3.5.1. Arithmetic Operators
Regular arithmetic operators such as +, −, *, and / are available in MDX. Just as with other programming languages, these operators can be applied on two numbers. The + and − operators can also be used as unary operators on numbers. Unary operators, as the name indicates, are 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 returns the union of two sets, the − operator returns the difference of two sets, and the * operator returns the cross product of two sets. The 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 two sets, {Male, Female} and {2003, 2004, 2005}, the cross product, represented as {Male, Female} * {2003, 2004, 2005}, is {(Male,2003), (Male,2004), (Male,2005),(Female,2003),(Female,2004),(Female,2005)}. The following examples show MDX expressions that use the set operators: ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access