Skip to content

Row context, filter context, and transition

Context is why a formula that looks correct can answer the wrong question. Always write the filter state alongside an expected value.

Filter context: which rows are eligible?

A Region slicer, a matrix's ProductName row, a date selection, and relationships can constrain Sales. [Revenue] sums the eligible SalesAmount values.

Context Revenue
No region/product/date restriction 9500
North 4100
South 5400
Laptop, all regions/dates 8000
Laptop and North 3000

Dimensions propagate their filters through the active single-direction relationships. A grand total is the measure evaluated in total context, not necessarily a sum of numbers already drawn on screen.

Row context: which row is being visited?

Revenue Iterator =
SUMX ( Sales, Sales[Quantity] * Sales[UnitPrice] )

SUMX creates a row context over the currently eligible Sales rows and evaluates Quantity * UnitPrice for each. A calculated column also starts with a row context over its own table.

A row context is not automatically a filter context. Writing an aggregate inside a calculated column does not mean it filters to just the current row. Related-table access and relationship direction need explicit reasoning.

Context transition

CALCULATE can convert the current row context into filter context. When a model measure is evaluated within a row context, context transition is automatic for that measure invocation.

For example, a ranking iterator evaluates [Revenue] for each product it visits. Replacing it with a bare aggregate can change the semantics because the aggregate is not a measure invocation with automatic transition. Do not "optimize" away the transition without preserving the contract.

Diagnose by shrinking the question

  1. Inspect the measure without the visual.
  2. State the current dimension filters.
  3. Check the relationship path to Sales.
  4. Add one filter/iterator at a time.
  5. Predict a small row/product result and the total separately.

Exercise: explain why a North/Laptop cell is 3000 while the North total is 4100. Then test the filter-intersection query.

Continue with CALCULATE. Reference: DAX context concepts.