Context Transition
Power BI · DAX (Data Analysis Expressions)
Theory
Context transition is what happens when CALCULATE runs inside a row context: the values of the current row are turned into filters. Every measure reference has an invisible CALCULATE around it, so referencing [Total Sales] inside a calculated column or an iterator also triggers context transition.
In a calculated column on Customers, SUM(Sales[Amount]) has no filter context, so every customer gets the grand total ₹6,200. Writing [Total Sales] (or CALCULATE(SUM(Sales[Amount]))) instead turns the current row, CustomerID = C1, into a filter that flows through the relationship to Sales, giving Asha ₹2,700, Ravi ₹2,400, Meera ₹600 and Karan ₹500. The same mechanism makes AVERAGEX(Customers, [Total Sales]) compute an average per customer. Context transition is powerful but can be expensive on large tables, and if the iterated table has duplicate rows, each duplicate filters the same rows and results can be multiplied.
Why we use it
It explains why a measure behaves differently from its raw formula inside a column or iterator, and it is the key to per-customer or per-product calculations.
When to use it
Use it intentionally: reference measures inside iterators over dimension tables (Customers, Products) to get per-entity results. Avoid iterating large fact tables with measure references, which forces a transition for every row.
How it works
- Row context exists (column or iterator)
- Is CALCULATE or a measure reference used? Yes: Row values become filter context. No: Expression sees no row filters.
- Filters flow through relationships to related tables
- Aggregation runs on the filtered rows
- Per-row result
Syntax
Triggered by: CALCULATE(<expr>) inside a row context, or any [Measure] reference inside a row context
Customers[Customer Sales] = [Total Sales] // with transition
Customers[Wrong Sales] = SUM(Sales[Amount]) // no transition → grand totalExample
// Calculated columns in Customers
Customer Sales = [Total Sales] // Asha 2,700, Ravi 2,400 …
Wrong Sales = SUM(Sales[Amount]) // 6,200 on every row
// Measure: average sales per customer
Avg Sales per Customer = AVERAGEX(Customers, [Total Sales])
// (2,700 + 2,400 + 600 + 500) / 4 = 1,550Key points
- CALCULATE inside row context turns the row into filters
- Every measure reference is wrapped in an implicit CALCULATE
- Filters from the row flow through relationships
- Iterating a fact table with measure references can be slow
- Duplicate rows in the iterated table can multiply results