MDX has the undeserved reputation of being a difficult language. Analysis Services expert Chris Webb makes it easy, introducing the three key MDX concepts: unique names, tuples, and sets, in this 29-minute, free video. Log-in or get a free account to watch it!
All objects in MDX, from cubes to dimensions to hierarchies, levels and members, have unique names. These are the names you should use when writing MDX to uniquely identify an object in a cube. You can determine the unique name of an object by clicking on it, in the metadata pane of an MDX query window in SQL Server Management Studio, and then dragging it into the query pane. Not using a unique name may seem like a good idea, because it makes your MDX code less verbose, but if you do you run the risk of Analysis Services returning a different object with the same name, which will result in errors, or unexpected results.
A tuple is a way of referring to a single value within a cube. If you think of a cube as a gigantic multidimensional array, a tuple is a co-ordinate to one cell within that array. Tuples are written as comma-delimited lists of members, from one or more different hierarchies, and are surrounded by round brackets: (). Tuples are most often used to return values in MDX calculations. You can see two examples of tuples in the demo, starting with a simpler one, and then a more complex one.
A set is an ordered list of members, or tuples, surrounded by curly brackets: {}. Each item in a set has to be the same type of a thing: for a set of members, each member has to be from the same hierarchy—although the members can be from different levels of the same hierarchy. Chris shows a demo of a set using members of the most commonly used hierarchy: the date hierarchy. For a set of tuples, each tuple has to contain the same number of members, and each tuple has to contain members from the same hierarchy in the same order. Sets are used to define what appears on the rows and columns of an MDX query, and are also used in calculations, for example when aggregating a large number of values.
Make sure to continue learning by watching Chris’s next video MDX Queries.