Multidimensional Expressions (MDX) is a language used to access and manipulate multidimensional (MD) information that is analagous to how SQL is used to access relational data.
MDX is used to make either MDX Statements or MDX Expressions:
Here is the basic syntax for an MDX SELECT statement. A dimension can only be specified in an axis or the slicer but not both and not in multiple axes.
[WITH FormulaSpec1[... FormulaSpecN] SELECT [AxisSpecs] FROM [Cube] [WHERE [SlicerSpecs]] [CellProperties]
The FormulaSpecs specfiy calculated or temporary members that can be used elsewhere in the MDX statement. Here is the syntax for a formula spec:
MEMBER ParentMember.MemberName AS 'ValueExpression'[, SOLVE ORDER = M][, CellProperty=ValueExpression ...]
The AxisSpecs specify the "edges" of a MD result set. An edge is a set assigned to an axis. The first five axes can be referenced by name or index (EG: AXIS(0) is COLUMNS), the rest are referenced by index. Up to 128 axes can be specified. The axes can be presented in any order but an axis cannot be skipped over, i.e. you can't present just Axis(0) and Axis (2). The axes are the mechanism for "dicing" the data set. Here is the syntax for axes:
[NON EMPTY] {Set} [DimensionProperties] ON {COLUMNS | ROWS | PAGES | SECTIONS | CHAPTERS | AXIS(Index)}, ...
Optionally the MDX keywords of NON EMPTY can be used to hide (i.e. not return) empty cells.
Optionally DimensionProperties, which can extend member information, may be included. Here is the syntax for DimensionProperties.
[DIMENSION] PROPERTIES property1 [, property2 ...]
The SlicerSpecs specify the "filter" of a MD result set. The SlicerSpecs must evaluate to a single tuple (i.e. not a set!). A set cannot be used in the WHERE clause. If a set is provided, then MDX will use the aggregate function on the set. The WHERE clause is the mechanism for "slicing" the data set. Note that the MDX function called "Filter" functions more like the SQL WHERE statement than the MDX WHERE statement. Here is the syntax for the WHERE statement:
WHERE tuple
Optionally CellProperties, which are used by MDX apps to visually represent the data, may be included. Here is the syntax for CellProperties.
CELL PROPERTIES property1 [, property2 ...]
The simplest possible MDX query has this syntax:
SELECT FROM MyCube
Here is another simple example:
WHERE MEMBER Measures.[Avg Price] AS 'Sales/[Units Sold]'
SELECT
{ [Measures].[Units Sold], [Measures].[Avg Price] } ON COLUMNS,
{ [Time].[1999], [Time].[2000] } ON ROWS
FROM Sales
WHERE ( [Store].[IL].[CA] )
Calculated Members do not store data in the cube but calculate values as needed. Calculated members are MDX expressions based upon existing measures and members. They are calculated at query time, after aggregations. Calculated members can slow query retrieval but they also do not require the cube to be reprocessed if the equation changes.
CREATE MEMBER CalculatedMemberTuple AS 'CalculatedMemberEquation'
WITH MEMBER CalculatedMebmerTuple AS 'CalculatedMemberEquation' [, SOLVE_ORDER = n] ... SELECT ....
Named Sets serve as aliases for sets.
CREATE SET SetAlias AS 'SetDefinition'
WITH SET SetAlias AS 'SetDefinition' SELECT ....
Comments in MDX are done in both SQL Server and c syntax.
-- . All text following until the end of the line are ignored.// . All text following until the end of the line are ignored./* ... */ . All text between the pairs are ignored.An OLAP object name must be bracketed if any of the following 3 conditions are met:
[Net Profit].[2000].[Select].Miscellany
Page Modified: (Hand noted: 2007-10-12 02:51:37Z) (Auto noted: 2007-11-17 06:46:00Z)