Filter context determines which rows are visible to a measure, while row context evaluates each row individually; CALCULATE triggers a context transition, converting row context to filter context.
How the contexts work
1. Row context – created automatically by iterators (SUMX, FILTER, ADDColumns). It lets you reference columns of the current row ([Sales], RELATED(Product[Category])).
2. Filter context – built from visual filters, slicers, and explicit filter functions (CALCULATE, FILTER, ALL). It restricts the data set before aggregation.
3. Context transition – when CALCULATE is evaluated, any existing row context is turned into an equivalent filter context, allowing row‑level calculations to affect the overall filter set.
Quick comparison
| Aspect | Row Context | Filter Context |
|-------------------|---------------------------------|------------------------------------|
| Origin | Iterator functions | Visuals, slicers, CALCULATE |
| Access | Direct column reference ([Col]) | Implicit via aggregation (SUM) |
| Conversion | → via CALCULATE (context transition) | N/A |
When to use CALCULATE
- You need to modify the current filter set (add, replace, or remove filters).
- You want to apply time‑intelligence (TOTALYTD, SAMEPERIODLASTYEAR).
- You must perform a context transition inside a row‑context iterator.
Decision checklist
- ☐ Is the measure inside an iterator (SUMX, FILTER)? → Use CALCULATE to convert row to filter context.
- ☐ Do you need to override a slicer selection? → Add a filter argument in CALCULATE.
- ☐ Are you calculating a running total or YTD value? → Wrap the time‑intelligence function in CALCULATE.
Example
Sales LY :=
CALCULATE(
SUM(Sales[Amount]),
SAMEPERIODLASTYEAR('Date'[Date])
)Top3 Products :=
CALCULATE(
SUMX(
TOPN(3, VALUES(Product[Name]), [Sales], DESC),
[Sales]
)
)