Q&A-1Explain row context and filter context with an example.
Answer
Core answer. Filter context is the set of filters in force when a value is evaluated: the visual's rows and columns, slicers, page and report filters, relationship propagation, RLS, and any filter arguments passed to CALCULATE. Row context is "which row am I on" during a calculated column or an iterator such as SUMX, FILTER, or ADDCOLUMNS. Row context does not filter anything on its own: it only lets you read the current row's columns. The two meet through context transition: referencing a measure (or wrapping in CALCULATE) inside a row context turns the current row's values into filters.
The example. Two tables: Products(Product, Category) and Sales(Product, Amount). Sales holds A→20, A→30, B→20.
Sales Amount = SUM ( Sales[Amount] ) -- measure
Product Sales = [Sales Amount] -- calculated column on ProductsThe calculated column is evaluated once per Products row, so each evaluation starts in a row context. Referencing the measure [Sales Amount] triggers context transition: the current row's Products[Product] becomes a filter on Sales[Product].
| Products row | Row context | After transition, filter on Sales | Result |
|---|---|---|---|
| A | Product = A | Sales[Product] = "A" | 20 + 30 = 50 |
| B | Product = B | Sales[Product] = "B" | 20 |
Put [Sales Amount] in a card instead and there is no row context, only filter context: the card's filter is the whole table, so it returns 70.
Why it behaves this way. A measure is defined to run under whatever filter context it is called in. A row context is not a filter context, so the engine has to convert one into the other before the measure can see a single product. That conversion is context transition, and it is why the same measure returns 50, 20, or 70 depending only on what surrounds it.
Alternatives and when to use them. A calculated column is computed at refresh, stored, and sliceable: good for a stable per-row attribute, but it bakes in the transition cost once per row at refresh. A measure computes at query time and adapts to any visual, at the cost of doing the work per query. Inside an iterator, SUMX ( Sales, Sales[Qty] * Sales[Price] ) uses row context with no transition and is cheaper; SUMX ( Sales, [Sales Amount] ) transitions once per Sales row and is the expensive pattern on a large fact table.
Failure modes. Writing Product Sales Wrong = SUM ( Sales[Amount] ) as a calculated column: SUM ignores row context and never transitions, so every Products row shows 70. Detected by a column whose values are all identical. Referencing a column from the one-side table inside a row context on the many side without RELATED returns blank or errors, because row context does not reach across the relationship. And a measure inside SUMX over a million-row fact table does a million transitions; detected as a query that is orders of magnitude slower than the equivalent SUMX over raw columns.
Curated: · Written: · Reviewed:
Log in free to save your progress and keep bookmarks and notes for a quick revision before your interview.