MDX (Multidimensional Expressions) is a query language for OLAP (Online Analytical Processing) databases, primarily used with Microsoft SQL Server Analysis Services (SSAS) and other multidimensional database systems. Unlike SQL's flat relational model, MDX navigates hierarchical cube structures with dimensions, measures, and complex aggregations. Its syntax resembles spreadsheet formulas and enables sophisticated time-based calculations, drill-down operations, and dynamic filtering across multiple dimensionsmaking it essential for business intelligence reporting and data analytics where users need to slice, dice, and pivot multidimensional data rapidly.
What This Cheat Sheet Covers
This topic spans 20 focused tables and 168 indexed concepts. Below is a complete table-by-table outline of this topic, spanning foundational concepts through advanced details.
Table 1: Query Structure Basics
Core MDX queries are built from SELECT, FROM, WHERE, and WITH clauses, each playing a distinct role; understanding how axes, slicer, and subselects interact is the foundation before writing any calculation.
| Component | Example | Description |
|---|---|---|
SELECT [Measures].[Sales] ON COLUMNS, [Product].[Category].Members ON ROWSFROM [SalesCube] | • Core query syntax specifying what to retrieve (axes), from which cube, and optional filtering • axes define result dimensionsCOLUMNS for column headers, ROWS for row headers | |
FROM [SalesCube] | • Specifies the target cube or subcube to query • can reference a physical cube or a subselect expression that restricts cube space | |
WHERE ([Time].[2025], [Geography].[USA]) | • Filters the entire result set by specifying a tuple forming the slicer axis • reduces cube dimensions globallyoften called the filter axis | |
WITH MEMBER [Measures].[Profit] AS [Measures].[Sales] - [Measures].[Cost]SELECT ... | • Defines query-scoped calculated members or named sets before the SELECT statement • members/sets only exist within this query, not persisted to cube |