#1 Data Analytics Program in India
₹2,499₹1,499Enroll Now
Module 8
5 min read

Filter Context

Understand how filters affect DAX calculations

What You'll Learn

  • What is filter context
  • How filters affect your measures
  • How to control filters with CALCULATE

What is Filter Context?

Filter context = what filters are active when a measure calculates.

Filter Context

Example:

Total Sales = SUM(Sales[Amount])
Active FilterResult
No filterAll sales ($500K)
Region = "East"East sales only ($150K)
Year = 20242024 sales only ($200K)
Both filtersEast + 2024 ($50K)

The same measure gives different results based on context!


Where Do Filters Come From?

Filter Sources

SourceExample
SlicersUser clicks "East"
Visual axesBar chart shows by Region
Filter panePage filter: Year = 2024
Cross-filterClick on another chart

All filters combine together!


CALCULATE: Control Your Filters

CALCULATE lets you change the filter context.

CALCULATE(expression, filter1, filter2, ...)

Add a Filter

USA Sales = CALCULATE([Total Sales], Country = "USA")

Remove All Filters

Grand Total = CALCULATE([Total Sales], ALL(Sales))

Practical Example: % of Total

Percentage of Total

% of Total =
DIVIDE(
    [Total Sales],
    CALCULATE([Total Sales], ALL(Sales))
)
RegionSales% of Total
East$150K30%
West$200K40%
North$150K30%
Total$500K100%

Quick Reference

NeedDAX
Add filterCALCULATE([Measure], Column = "Value")
Remove all filtersCALCULATE([Measure], ALL(Table))
Remove one filterCALCULATE([Measure], ALL(Column))
Keep some filtersALLEXCEPT(Table, Column)

Try This

  1. Create: Total Sales = SUM(Sales[Amount])
  2. Create: Grand Total = CALCULATE([Total Sales], ALL(Sales))
  3. Create: % of Total = DIVIDE([Total Sales], [Grand Total])
  4. Add to a table by Region
  5. Add a Region slicer and test!

Tip: Understanding filter context = understanding DAX. This is the foundation of everything!