What is the difference between tuple
and set
in MDX. How we can distinguish both and when we are using them.
A tuple uniquely identifies a slice of data from a cube. The tuple is formed by a combination of dimension members, as long as there are no two or more members that belong to the same hierarchy.
An MDX calculated member is defined by creating and building an MDX expression. Procedure. To create an MDX calculated member: In the Data Project Explorer, expand the cube model that contains the dimension object for which you want to create an MDX calculated member under its hierarchies.
MDX is a query language designed for OLAP databases, as SQL is a query language for relational databases. MDX is essentially an extension to SQL used for queries and script access to multidimensional data. MDX queries access data stored in a SQL Server Analysis Server cube by bringing back facts related to dimensions.
Multidimensional Expressions (MDX) is a query language for online analytical processing (OLAP) using a database management system. Much like SQL, it is a query language for OLAP cubes. It is also a calculation language, with syntax similar to spreadsheet formulas.
Having come to MDX from a more maths perspective this is my take on the question:
Imagine you have 3d Cube with dimensions X, Y and Z. The number of cells in the cube is number of members in X multiplied by the number of members of Y multiplied by the number of members of Z.
Each cell with have a coordinate in the cube based on a value from X, Y and Z. That coordinate is a Tuple.
So lets say :
Then a single cell could be the laptop sales for 1999. The cell coordinate will be:
logically (X, Y, Z)
and physically this is a tuple such as
(Measures.Sales, Years.[1999], Products.[Laptop])
Now lets say we want multiple cells, then we need multiple tuples, right? Yes, a Set is basically multiple tuples. Actually by multiple I include 0 and 1. So extending our example, we could have laptops from 1999 and desktops from 2001:
{
(Measures.Sales, Years.[1999], Products.[Laptop]) ,
(Measures.Sales, Years.[2001], Products.[Desktop])
}
So you can see that you end up with multiple items with a set, and a single item with a tuple......
A tuple is a single hierarchy member taken from all the dimensions.
Suppose Time.[2nd half]
is a tuple of time dimension. At the same way we can have multiple tuples and we represent them in '(',')' brackets.
Eg:
(Time.[2nd half], Color.Dark.Red).
This is nothing but the mathematical intersection of nodes. we can represent the nodes in maths as (2,1) in the same way above expression will work.
Now coming to sets it is nothing but the composition of tuples. set contains one or more tuples it may zero also. we represent them in { , } braces. Eg:
{ (Time.[1st half], Color.Dark.Red), (Time.[2nd half], Color.Dark.Blue) }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With