Overview
MDX (Multidimensional Expressions) is a query language for Microsoft SQL Server Analysis Services (SSAS) and other OLAP databases. It enables you to retrieve and manipulate multidimensional data stored in cubes.
Key Concepts
- Dimensions – Logical categories such as Time, Geography, Product.
- Hierarchies – Ordered levels within a dimension (e.g., Year → Quarter → Month).
- Measures – Numeric values that can be aggregated (e.g., Sales Amount).
- Members – Individual elements of a hierarchy.
- Tuples & Sets – Tuples are ordered collections of members; sets are ordered collections of tuples.
Getting Started
Open SQL Server Management Studio (SSMS) and connect to an Analysis Services instance. Use a new MDX query window to start writing queries.
Popular Functions
| Function | Category | Description |
|---|---|---|
| SUM | Aggregate | Returns the sum of a numeric expression evaluated over a set. |
| AVG | Aggregate | Returns the average value of a numeric expression evaluated over a set. |
| YTD | Time | Returns a set of periods from the beginning of the year up to the current period. |
| ParallelPeriod | Time | Returns a member from a prior period relative to a given member. |
| Axis | Utility | Returns the specified axis of the current query. |