How to Handle Context Transition in Power BI
Understand row and filter context in DAX and avoid common pitfalls.
Filter context, row context, and context transition are central to getting DAX right in Power BI. Unlike Excel, where you see filters on the grid, Power BI applies filters behind the scenes. Understanding how context flows—and when it changes—helps you write correct measures and avoid subtle bugs.
Filter context
Filter context is the set of filters coming from the report: slicer selections, rows and columns on a matrix, filters on the visual or page. Before any measure runs, that filter context is applied to the model. The measure then runs on the filtered data. Example: in a table with Region on rows and a measure Sales_Amount = SUM(Orders[Sales]), the value for the West row is computed by first filtering Orders so Region = West, then summing Sales.
Row context
Row context means the formula is evaluated once per row. Calculated columns run in row context: each row sees its own values. In a measure, there is no row context unless you are inside an iterator such as SUMX, AVERAGEX, or FILTER. In a calculated column you can write Total Sales = Orders[Quantity] * Orders[Unit Price] because the engine iterates row by row. In a measure, you need an iterator to get row-by-row logic.
// Calculated column (row context): each row gets its own result
Total Sales = Orders[Quantity] * Orders[Unit Price]
// Measure with iterator (row context inside SUMX):
Total Sales Measure = SUMX(Orders, Orders[Quantity] * Orders[Unit Price])Context transition
Context transition happens when a DAX expression that uses CALCULATE (or invokes it, e.g. via a measure) is evaluated inside a row context. The current row's values are turned into filters for the inner calculation. So you can switch from row context to an equivalent filter context for that row. Example: in a table visual, a measure that uses CALCULATE inside an iterator can give total for this row style results.
// Context transition: row values become filters
Max Single Day Sales =
MAXX(VALUES(Orders[Order Date]), CALCULATE(SUM(Orders[Sales])))Context transition traps
- Performance: context transition can be expensive. In an iterator over many rows, each iteration may re-filter the model.
- Cardinality: high-cardinality columns can lead to large filter contexts or unexpected results.
- Not one row: context transition applies the row's values as filters, which can match multiple rows in related tables.
- Debugging: hidden columns or relationships can change filter context in non-obvious ways.
Summary
Filter context comes from the report. Row context exists in calculated columns and inside iterators. Context transition (e.g. CALCULATE inside a row context) turns row values into filters. Use iterators when you need row-by-row logic in a measure, and use CALCULATE when you need to change or introduce filter context.
Need help with your migration?
Our team can help you design, build, and optimize your Power BI and Fabric solutions.
Get a free assessmentReady to modernize your BI stack?
Stop maintaining legacy workbooks. Start leveraging the full power of the Microsoft Data Platform today.