Row Context vs Filter Context
Understanding evaluation context is the most important concept in DAX. It determines how DAX formulas are evaluated and what data they operate on.
What is Evaluation Context?
Evaluation context defines which rows of data a DAX expression sees when it is being calculated. There are two types:
1. Row Context
• Exists when DAX iterates over a table row by row • Each row is evaluated independently • Created automatically in calculated columns • Also created by iterator functions: SUMX, AVERAGEX, FILTER, MAXX, etc.
Example (Calculated Column):
Profit = Sales[Revenue] - Sales[Cost]
Here, DAX evaluates each row individually — [Revenue] and [Cost] refer to the values in the current row.
Example (Iterator):
Total Profit = SUMX(Sales, Sales[Revenue] - Sales[Cost])
SUMX creates a row context, evaluates Revenue - Cost for each row, then sums the results.
2. Filter Context
• Exists when external filters are applied to the data • Determines which rows are visible to the formula • Created by slicers, report filters, visual filters, and CALCULATE • Affects measures and aggregate functions
Example (Measure):
Total Sales = SUM(Sales[Amount])
If a slicer is set to "2024", this measure only sums Amount for rows where Year = 2024.
Key Differences
| Feature | Row Context | Filter Context |
|---|---|---|
| When Created | Calculated columns, iterator functions | Slicers, filters, CALCULATE |
| Scope | One row at a time | Entire filtered table |
| References | Column values in current row | Aggregated values across filtered rows |
| Example | Sales[Revenue] - Sales[Cost] | SUM(Sales[Amount]) |
| Automatic in | Calculated columns | Measures |
Context Transition
What is Context Transition? When CALCULATE converts a row context into a filter context. This is a critical concept for intermediate DAX users.
How it Works: • Inside an iterator (SUMX, FILTER, etc.), there is row context • When a measure is called inside that iterator, CALCULATE wraps it • The row context values become filter conditions • This creates a new filter context for that specific row
Example:
Running Total =
SUMX(
Dates,
[Total Sales] -- [Total Sales] measure triggers context transition
)
Common Mistakes
• Expecting row context in measures — measures don't have row context by default • Ignoring filter context in calculated columns — calculated columns don't respond to slicers • Not understanding that CALCULATE modifies filter context — this is key to advanced DAX
Best Practice
• Use measures for dynamic calculations (they respond to filter context) • Use calculated columns only when you need row-level values or slicers • Always think: "What context will this formula evaluate in?"