TUTORIAL: Introduction to Multidimensional
Expressions (MDX)
Summary: This tutorial introduces multidimensional expressions (MDX), a highly
functional expression syntax for querying multidimensional data in Microsoft SQL
Server OLAP Services. It also discusses the structure of OLAP Services cubes and
explores the features of MDX.
Contents
Introduction .....................................................................................................................2
0. Multidimensional Expressions ....................................................................................3
Cube Concepts.............................................................................................................3
FoodMart Sales Cube ..................................................................................................4
1. Getting Started with MDX ..........................................................................................6
Slicer specifications.....................................................................................................9
2. Core MDX Functionality...........................................................................................11
Calculated Members and Named Sets .......................................................................11
Hierarchical Navigation.............................................................................................14
Time Series Functions ...............................................................................................18
Tuples and CROSSJOIN ...........................................................................................21
Filtering and Sorting..................................................................................................23
Top and Bottom Performance Analysis.....................................................................26
Numeric Functions and Conditional Expressions .....................................................28
3. Conclusion.................................................................................................................33
Introduction
Microsoft SQL Server OLAP Services provides an architecture for access to
multidimensional data. This data is summarized, organized, and stored in
multidimensional structures for rapid response to user queries. Through OLE DB for
OLAP, a PivotTable Service provides client access to this multidimensional online
analytical processing (OLAP) data. For expressing queries to this data, OLE DB for
OLAP employs a full-fledged, highly functional expression syntax: multidimensional
expressions (MDX).
OLAP Services supports MDX functions as a full language implementation for creating
and querying cube data. The querying capabilities of this language are the focus of
this article. To demonstrate these capabilities, we will utilize whenever possible
simple real-world sample expressions. These are based on the Sales cube in the
sample FoodMart database that is installed with OLAP Services. The MDX expressions
can thus be run to view the actual output.
OLE DB for OLAP is a set of Component Object Model (COM) interfaces designed to
extend OLE DB for efficient access to multidimensional data. ADO has been extended
with new objects, collections, and methods that are designed to take advantage of
OLE DB for OLAP. These extensions are collectively known as ADO MD
(multidimensional) and are designed to provide a simple, high-level object model for
accessing tabular and OLAP data.
This description of MDX assumes the reader is familiar with multidimensional data
warehousing and OLAP terms.
To run the sample queries you will need:
• Microsoft SQL Server 2000 Analysis Services (or Microsoft SQL Server 7 OLAP