By Fatskills Exam Guides Team — the exam nerds behind 28,500+ quizzes and 2.1M practice questions across 500+ global exams.
A Hyper-Practical, Zero-Fluff Study Guide
What it is:CALCULATE is Power BI’s most powerful DAX function—it lets you modify filter context on the fly. But its default behavior (overwriting filters) often causes unexpected results. KEEPFILTERS, CROSSFILTER, and ALLEXCEPT are filter modifiers that give you surgical control over how CALCULATE interacts with existing filters.
CALCULATE
KEEPFILTERS
CROSSFILTER
ALLEXCEPT
Why it matters in production:- Broken reports: Without these modifiers, your measures might return wrong totals (e.g., showing global sales instead of filtered sales).- Performance nightmares: Misusing CALCULATE can force Power BI to scan entire tables, killing performance.- Real-world scenario: You’re building a sales dashboard. A user filters by Region = "West", but your "Total Sales" measure ignores the filter and shows all regions. Or worse—your "YoY Growth" measure breaks because it’s comparing filtered vs. unfiltered data.
Superpower: These modifiers let you preserve, override, or selectively clear filters—critical for accurate comparisons, dynamic aggregations, and complex business logic.
BLANK()
ALL
SUMX
FILTER
USERELATIONSHIP
Sales
SaleID
ProductID
Region
Amount
Products
Category
Sales[ProductID] → Products[ProductID]
Goal: Show total sales excluding the currently filtered product category (e.g., if user filters "Electronics," show sales for all other categories).
Total Sales
Total Sales = SUM(Sales[Amount])
Sales Excluding Category (Broken) = CALCULATE( [Total Sales], ALL(Products[Category]) // Clears ALL category filters )
Problem: This always shows global sales, ignoring all user filters (e.g., region, date).
Sales Excluding Category = CALCULATE( [Total Sales], KEEPFILTERS(ALL(Products[Category])) // Preserves other filters )
How it works:- ALL(Products[Category]) clears only category filters.- KEEPFILTERS ensures other filters (e.g., region) are preserved.
ALL(Products[Category])
Products[Category]
[Total Sales]
[Sales Excluding Category]
Region = "West"
Scenario: You need a measure that shows sales for products not in the current category, but only for products with >$1K in sales.
Sales Excluding Category (Filtered) = CALCULATE( [Total Sales], KEEPFILTERS(ALL(Products[Category])), CROSSFILTER(Sales[ProductID], Products[ProductID], NONE), // Disable relationship FILTER( ALL(Products), [Total Sales] > 1000 // Only include products with >$1K sales ) )
Why CROSSFILTER?- Disables the relationship to avoid circular dependencies.- Lets FILTER work on the Products table without affecting Sales.
Scenario: You need a "Sales Last Year" measure that ignores all filters except the date.
Sales LY = CALCULATE( [Total Sales], ALLEXCEPT('Date', 'Date'[Year]), // Preserve only year filter DATEADD('Date'[Date], -1, YEAR) // Shift date back 1 year )
Key insight:- ALLEXCEPT is safer than ALL because it preserves critical filters (e.g., year).- Without it, DATEADD might return BLANK() if other filters conflict.
DATEADD
REMOVEFILTERS
DAX Studio
Sales Excluding Category (KEEPFILTERS)
dax // Preserves region/date filters but clears category KEEPFILTERS(ALL(Products[Category]))
VAR
dax Sales Excluding Category = VAR CurrentCategory = SELECTEDVALUE(Products[Category]) RETURN CALCULATE( [Total Sales], KEEPFILTERS(ALL(Products[Category])) )
ISBLANK
dax Sales LY (Safe) = IF( ISBLANK([Total Sales]), BLANK(), CALCULATE([Total Sales], DATEADD('Date'[Date], -1, YEAR)) )
ALLEXCEPT('Date', 'Date'[Year])
REMOVEFILTERS(Products[Category])
✅ KEEPFILTERS (preserves filters)
"How do you ignore all filters except date?"
ALL('Date')
✅ ALLEXCEPT('Date', 'Date'[Year]) (preserves year filter)
"Why does this measure return BLANK()?" dax Sales LY = CALCULATE( [Total Sales], DATEADD('Date'[Date], -1, YEAR) )
dax Sales LY = CALCULATE( [Total Sales], DATEADD('Date'[Date], -1, YEAR) )
ALLEXCEPT(Table, Column)
Column
Scenario: You have a Sales table with Region and Product columns. Create a measure that shows: - Total sales for the current region (e.g., "West").- Total sales for all other regions (e.g., "East + North + South").
Product
Requirements:- Must work with slicers (e.g., if user filters by Product = "Laptop", the measure should respect that).- Must not use hardcoded region names.
Product = "Laptop"
Sales Other Regions = VAR CurrentRegion = SELECTEDVALUE(Sales[Region]) RETURN CALCULATE( [Total Sales], KEEPFILTERS(ALL(Sales[Region])), // Clear region filter but keep others Sales[Region] <> CurrentRegion // Filter for other regions )
Why it works:- KEEPFILTERS preserves product/date filters.- ALL(Sales[Region]) clears the region filter temporarily.- Sales[Region] <> CurrentRegion filters for other regions.
ALL(Sales[Region])
Sales[Region] <> CurrentRegion
KEEPFILTERS(<filter>)
CROSSFILTER(Table1[Col], Table2[Col], NONE)
ALLEXCEPT(Table, Column1, Column2)
REMOVEFILTERS(Table[Column])
USERELATIONSHIP(Table1[Col], Table2[Col])
Join 4M+ learners. Unlock unlimited quizzes, wrong-answer tracking, flashcards + reminders, study guides, and 1-on-1 challenges.