DAX filter context and context transition, explained

What filter context and row context are in DAX, what CALCULATE changes, and how context transition turns a row into a filter, with measures that show it.

Short answer: filter context is the set of filters in force when a measure is calculated: the slicers, the row and column of the visual, and any filter CALCULATE adds. Row context is "the current row" while DAX walks a table, in a calculated column or an iterator like SUMX. Context transition is what CALCULATE does with a row context: it turns the current row into filters, so a measure inside an iterator is calculated for that row.

Almost every "why is my total wrong" in DAX comes down to which context a piece of the formula runs in.

Where does filter context come from?

  1. 1
    SlicerYear = 2026
  2. 2
    Matrix rowCustomer[Region] = "West"
  3. 3
    Matrix columnProduct[Category] = "Bikes"
  4. 4
    CALCULATEcan add, replace or remove filters
  5. 5
    MeasureSUM(Sales[Amount]) over the rows left
The filters behind one cell in a matrix

The same measure gives a different number in every cell because each cell has a different filter context, not because the formula changed.

Revenue = SUM ( Sales[Amount] )
Revenue all regions = CALCULATE ( [Revenue], REMOVEFILTERS ( Customer[Region] ) )
Share of region = DIVIDE ( [Revenue], [Revenue all regions] )

What is context transition?

An iterator walks a table row by row. Inside it, a column reference reads the current row, but a measure is always evaluated in a filter context. So DAX wraps the measure in an invisible CALCULATE, which turns the current row into filters: that is context transition.

-- Average revenue per customer: [Revenue] runs once per customer
Avg revenue per customer =
AVERAGEX ( VALUES ( Customer[CustomerID] ), [Revenue] )

-- Without the measure there is no transition: this sums every sale for every customer
Wrong average =
AVERAGEX ( VALUES ( Customer[CustomerID] ), SUM ( Sales[Amount] ) )
Inside AVERAGEXFilters per customer rowResult
[Revenue] (a measure)yes, CustomerID = the current onerevenue of that customer
SUM(Sales[Amount])noall revenue, for every customer
CALCULATE(SUM(Sales[Amount]))yesrevenue of that customer
The same iterator, with and without context transition

What goes wrong?

  • A measure inside a calculated column. Context transition fires for every row and filters by every column of that row. On a table with duplicate rows the result surprises; it is also slow on big tables.
  • Iterating a large table with a measure inside. Each row is a new filter context. Iterate the smallest table that answers the question, like VALUES(Customer[CustomerID]), not Sales.
  • FILTER on a whole table where a column filter in CALCULATE would do. CALCULATE([Revenue], Customer[Region] = "West") is clearer and faster.

Where can you check this?

Where do you start?

The open course DAX measures that add up has a lesson on exactly this: CALCULATE changes the filter, and a measure inside a row. Then Every KPI once puts it to work in a calculation group.

Keep reading

More from the blog.

Every post

Next

Building this? Say hello.

A question about this post, a pattern you would build differently, or the next thing you want written out: Behnia reads every message.