levselector.com New York
home > MDX Language  Email

MDX Language.

intro home - top of the page - email

Multidimensional Expression (MDX) language is used in Microsoft SQL Server OLAP services. MDX is to multidimensional cubes as SQL is to relational tables, so OLAP Services use MDX as its query language.
 
 
SQL MDX
SELECT 
  a, b, c  
FROM 
  t2, t2, t3 
WHERE { something } 
SELECT 
  { a, b, c } on columns, 
  { d, e, f } on rows
  { g, h, i } on pages
FROM some_cube
WHERE { something }

Example:

SELECT
  { [Measures].[Sales], [Measures].[Costs] } on columns,
  { [Time].[June-1998], [Time].[July-1998] } on rows
FROM TrivialCube
WHERE { [ Stores].[Downtown] }

[Time].[All Time]
[Time].[All Time].[1998]
[Time].[All Time].[1998].[Quarter 1]
[Time].[All Time].[1998].[Quarter 1].[January]

[Geography].[Store].[SquareFootage]

Why to use square brackets ??
Because you can not really anticipate all the other names that may come into play when they are used in new ways later on.

Tuple = collection of members from different dimensions.
Example of a tuple with 5 elements (enclosed in round brackets):
[Store].[NYC Fith Avenue Store][Time][1998][Product].[Leather Jackets][Scenario].[Actual][Measure].[Sales]  )

Set = ordered collection of tuples. Set may have zero, one, or more tuples. It may contain the same tuple more than once. Usually a set is specified by enclosing its members in curly brackets.  All tuples in a set must have the same dimensionality (set of dimensions and their order).

Thus you can not combine these 2 tuples into one set:

1.    (  [Time].[1998],          [Product].[Jacket]  )
2.   (   [Product].[Jacket] ,     [Time].[1998]  )
 
 
 

A set consisting of one member is NOT the same as a tuple consisting from the same member.