MDX Basic Concepts

26 October 2012 · 1 comment · 7686 views

Loading the player...

If this message stays on, check that you have the latest Flash Player installed (http://get.adobe.com/flashplayer) and that your browser supports JavaScript.

Unique Names, Tuples & Sets

Having a good understanding of the basic theory of MDX is essential if you want to be able to write your own calculations, and queries, for SQL Server Analysis Services and even PowerPivot in Excel. In this 29-minute video, world-renowned SSAS expert Chris Webb introduces three basic concepts in MDX: unique names, tuples, and sets. 

All objects in MDX, from cubes to dimensions to hierarchies, levels and members, have unique names (1:08). 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 (1:57). 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 (13:35). 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 (15:02), and then a more complex one (17:28). 

A set (19:45) 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 (21:04). For a set of tuples (24:06), 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.

Chris Webb also provides consultancy on MDX, Analysis Services, PowerPivot and DAX through Crossjoin Consulting, and he runs public training courses in the UK, taught by him, and by other leading SQL Server experts, through Technitrain.

Comments

Anil · 1 November 2012

Hi Chris,
Nice to know about this site and that was a simple n great session about MDX from a MDX Master I must say :). Hope to watch more session from you .!!!
Thanks,
Anil Maharjan