Microsoft Docs

Core DAX Concepts

Data Analysis Expressions (DAX) is a formula expression language used in Analysis Services, Power BI, and Power Pivot in Excel. DAX enables you to define custom calculations and data manipulation beyond what is achievable with standard data modeling techniques. Understanding the core concepts of DAX is crucial for building robust and efficient analytical models.

Formulas and Calculations

DAX formulas are used to create calculated columns, measures, and row-level security roles. They consist of functions, operators, and constants. The syntax is designed to be familiar to users of spreadsheet applications.

Calculated Columns vs. Measures

A fundamental distinction in DAX is between calculated columns and measures:

Filter Context

Filter context is one of the most important concepts in DAX. It represents the set of filters that are applied to the data model at any given time, influencing the result of a measure. This context can be derived from:

Understanding how filter context flows and how to manipulate it is key to writing correct DAX.

Row Context

Row context is the current row being processed in a table. This context is inherent in calculated columns, where the formula is evaluated for each row individually. It can also be introduced into measures using iterator functions (like SUMX, AVERAGEX) or by functions like RELATED.

Evaluation Context

Evaluation context is the combination of Filter Context and Row Context. When a DAX formula is evaluated, it operates within the current evaluation context. This context determines which rows are visible and what values are available for calculation.

CALCULATE Function

The CALCULATE function is arguably the most powerful and frequently used function in DAX. It allows you to modify the filter context in which an expression is evaluated. Its syntax is:

CALCULATE(, , , ...)

Where <expression> is typically a measure or another DAX expression, and <filter> arguments can be boolean expressions, table filters, or other filter modifications.

Table Functions

DAX includes many functions that return entire tables. These are often used within other DAX functions, particularly CALCULATE, to filter or transform data. Examples include:

Data Types

DAX supports several data types, including integers, decimals, currency, dates, strings, booleans, and more. Understanding data types is important for using functions correctly and ensuring accurate calculations.

Relationships

Relationships between tables in your data model are crucial. DAX functions often traverse these relationships to aggregate data or retrieve related values. Functions like RELATED() and RELATEDTABLE() are used to work with these relationships.

Mastering these core DAX concepts will provide a strong foundation for building sophisticated business intelligence solutions with Analysis Services and Power BI.