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, 143 flashcards. Below is a complete table-by-table outline of this topic, spanning foundational concepts through advanced details.
A jump-to index of every table row in this cheat sheet.
An interactive map of every table and concept in this topic.
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 | ||
SELECT NON EMPTY [Product].Members ON ROWS | • Excludes members or tuples with no data (all NULL/empty measures) • significantly improves performance by reducing result set size | ||
{[Product].[Bikes], [Product].[Clothing]} ON COLUMNS | • Defines a set of members to display on a specific axis • COLUMNS (Axis 0), ROWS (Axis 1), PAGES (Axis 2), SECTIONS (Axis 3), CHAPTERS (Axis 4) | ||
SELECT [Measures].[Sales] ON COLUMNSFROM ( SELECT [Time].[2025].Children ON COLUMNS FROM [SalesCube])WHERE [Geography].[USA] | • Nested SELECT in FROM clause that restricts cube space before outer query evaluation • changes hierarchy structure and filters differently than WHERE clause | ||
NON EMPTY [Product].Members HAVING [Measures].[Sales] > 1000 ON ROWS | • Filters axis contents after NON EMPTY is applied • alternative to FILTERcleaner syntax for axis-level conditions, evaluates in axis scope |