Filter Context is one of the most important concepts in DAX. It refers to the set of data that is currently filtered when a calculation is performed.
In simple terms, Filter Context means calculations change based on filters applied in a report.
Filters can come from:
- Visuals (charts, tables, cards)
- Slicers
- Page-level filters
- Report-level filters
- Relationships between tables
Example of Filter Context
Consider the following measure:
Total Sales = SUM(Sales[Amount])
If you place this measure in a card visual, it will show total sales for all data.
If you add a slicer for Year and select 2024, the measure will automatically show sales only for 2024.
The formula does not change, but the result changes because the Filter Context changes.
Filter Context in Visuals
When you use a visual like a table with Region and Total Sales:
- For Region = North, the measure calculates only North sales.
- For Region = South, the measure calculates only South sales.
Each row in the visual creates a different Filter Context.
Modifying Filter Context with CALCULATE
The CALCULATE function allows you to change or override the existing Filter Context.
Example
Sales 2024 = CALCULATE(
SUM(Sales[Amount]),
Sales[Year] = 2024
)
This measure forces the calculation to consider only data where Year = 2024, regardless of other filters.
Filter Context vs Row Context
Row Context works one row at a time.
Filter Context works on filtered sets of data.
Measures mainly work with Filter Context.
Calculated Columns mainly work with Row Context.
Why Filter Context is Important
- Makes reports dynamic and interactive
- Allows calculations to respond to slicers and filters
- Essential for time intelligence and advanced DAX
- Required for building KPIs and dashboards
Conclusion
Filter Context controls which data is included in a calculation. Understanding it is essential for writing effective DAX measures and building powerful Power BI reports.