Understanding Filter Context
Filter context is the set of filters currently in effect when a DAX measure is evaluated, built up from row and column headers in a visual, slicers, page filters, and any filters embedded directly in report-level interactions. A matrix visual with Region on rows and Year on columns creates a distinct filter context for every cell, so the same measure, such as SUM(Sales[Amount]), returns a different number in each cell because it is only summing the rows that survive that cell's specific combination of filters.
Cricket analogy: Filter context is like a DRS review that narrows the umpire's decision down to just the specific delivery in question, so the same 'is it out' measure gives a different verdict depending on which ball is filtered into view.
Row Context vs Filter Context
Row context exists automatically inside calculated columns and inside iterator functions like SUMX, representing 'the current row' being evaluated, but on its own a row context does not filter related tables the way filter context does; referencing a column from a related table inside a row context requires the RELATED function to pull that related row's value across the relationship. This distinction trips up beginners who expect a calculated column to automatically respect the same filtering behavior a measure would show in a visual.
Cricket analogy: Row context is like standing at the crease facing one specific ball, aware only of that delivery, and just as a batsman needs the scoreboard to know the wider match situation, a calculated column needs RELATED to pull in a connected table's value.
CALCULATE: Modifying Filter Context
CALCULATE is the only DAX function that can directly modify filter context, taking an expression as its first argument followed by any number of filter arguments; CALCULATE(SUM(Sales[Amount]), Sales[Region]="West") overrides whatever Region filter already exists in the visual and replaces it with just West, while CALCULATE(SUM(Sales[Amount]), ALL(Sales[Region])) removes the Region filter entirely so the measure ignores whichever region a user has sliced by. Because filter arguments in CALCULATE replace existing filters on the same column rather than adding to them, understanding this replace-not-add-by-default behavior is essential for writing correct measures.
Cricket analogy: CALCULATE overriding an existing Region filter is like a match referee overruling the on-field umpire's original call, replacing it entirely with a new decision rather than adding a second, conflicting ruling.
Sales West =
CALCULATE(
SUM(Sales[Amount]),
Sales[Region] = "West"
)
Sales Excluding Region Filter =
CALCULATE(
SUM(Sales[Amount]),
ALL(Sales[Region])
)
Running Total =
CALCULATE(
SUM(Sales[Amount]),
FILTER(
ALL('Date'[Date]),
'Date'[Date] <= MAX('Date'[Date])
)
)Context Transition
When CALCULATE is invoked inside a row context, such as within a calculated column or inside an iterator like SUMX, it performs context transition: the values of every column in the current row are converted into an equivalent set of filters, effectively turning row context into filter context for that evaluation. This is why a calculated column like Running Total = CALCULATE(SUM(Sales[Amount]), Sales[Date] <= EARLIER(Sales[Date])) can compute a cumulative total using the current row's date as an implicit filter, something that would be impossible without CALCULATE's context transition behavior.
Cricket analogy: Context transition converting the current row into a filter is like a third umpire freezing a single delivery from the broadcast feed and treating that exact moment as the entire frame of reference for a review.
CALCULATE's filter arguments replace any existing filter on the same column by default rather than adding to it — CALCULATE(SUM(Sales[Amount]), Sales[Region]="West") will show West's sales even if a report page filter is set to "East", because the CALCULATE filter wins.
CALCULATE is the only DAX function that can directly write to filter context. Every other function, including SUMX and FILTER, only reads the filter context that's already in effect.
- Filter context is the combination of slicers, visual rows/columns, and page filters active when a measure evaluates.
- Row context exists inside calculated columns and iterators, representing 'the current row.'
- Row context does not automatically filter related tables — use RELATED to pull related values.
- CALCULATE is the only DAX function that can directly modify filter context.
- CALCULATE's filter arguments replace, not add to, existing filters on the same column.
- ALL() removes filters from a table or column, often used inside CALCULATE.
- Context transition converts row context into filter context whenever CALCULATE runs inside a row context.
Practice what you learned
1. What is filter context?
2. Which function is required to pull a value from a related table while inside row context?
3. By default, how does a CALCULATE filter argument affect an existing filter on the same column?
4. What does CALCULATE(SUM(Sales[Amount]), ALL(Sales[Region])) do?
5. What is context transition?
Was this page helpful?
You May Also Like
Introduction to DAX
DAX (Data Analysis Expressions) is the formula language powering calculations in Power BI, Excel Power Pivot, and Analysis Services.
DAX Variables and Iterators
VAR and RETURN make complex DAX measures more readable and performant by caching intermediate results, especially when combined with iterator functions.
Time Intelligence in DAX
Time intelligence functions like TOTALYTD, SAMEPERIODLASTYEAR, and DATEADD let DAX measures compare and accumulate values across calendar periods.
Related Reading
Related Study Notes in Programming
Browse all study notesApache Spark Study Notes
Programming · 30 topics
ProgrammingApache Flink Study Notes
Programming · 30 topics
ProgrammingHadoop Study Notes
Programming · 30 topics
ProgrammingSnowflake Study Notes
Programming · 30 topics
ProgrammingApache Airflow Study Notes
Programming · 30 topics
Programmingdbt (Data Build Tool) Study Notes
Programming · 30 topics