Foundations › Power BI › DAX: Calculate Smartly
DAX: Calculate SmartlyFilter Context and CALCULATE: Why One Measure Gives Different Numbers
You open a report with a single measure called Total Sales. In a card it shows 7.3 million, in a chart three different numbers, in a matrix dozens. Did the formula change? No. What changed is the filter context.
What is filter context?
It is the set of filters active at the moment Power BI evaluates the measure. Its sources: a slicer you picked from, the row or column of a matrix, the chart axis, page and report filters, and CALCULATE inside the formula itself. A filter on a dimension table (like DimProduct) then flows to the fact table through the relationship.
Total Sales = SUM(FactSales[Sales])Same formula, a different split: every row here is a different filter context (a different year). Change the by to DimProduct[Category] or DimChannel[Channel].
In the lab above pick a year, channel and city and watch the active filters and how many rows entered the calculation. Notice that the City filter (on DimCustomer) changed sales even though City is not a column of FactSales: the relationship carried it.
CALCULATE: it changes the filter
CALCULATE evaluates an expression in a modified context: CALCULATE(expression, filter1, filter2…). A new filter on a column replaces the existing filter on that same column; it does not intersect with it.
Total Sales = SUM(FactSales[Sales])
Online Sales = CALCULATE([Total Sales], DimChannel[Channel] = "Online")
Store Sales = CALCULATE([Total Sales], DimChannel[Channel] = "Store")Each year shows both channels next to the total, using the same rule.
Total Sales = SUM(FactSales[Sales])
Online Sales = CALCULATE([Total Sales], DimChannel[Channel] = "Online")The outer filter here is Channel = Store. Total Sales stayed on Store, but Online Sales replaced the filter and returned Online sales. That is the key idea of the lesson.
REMOVEFILTERS: take a filter away
Total Sales = SUM(FactSales[Sales])
All Cities Sales = CALCULATE([Total Sales], REMOVEFILTERS(DimCustomer[City]))
City Share = DIVIDE([Total Sales], [All Cities Sales])The outer filter is City = Cairo. All Cities Sales removed the city filter and returned all-city sales, so City Share is Cairo's share of the total.
🧩 Classify each item: does it create a filter in the filter context?
❓ The year slicer is 2025 and the measure is CALCULATE([Total Sales], DimDate[Year] = 2024). What will show?
CALCULATE replaces the filter on Year, so the measure calculates 2024 regardless of the slicer.
Exercise 1 — Write a measure named Answer that always returns Online-channel sales, even when the outer filter is another channel.
Exercise 2 — Write a measure named Answer that always returns 2024 sales, whatever year the slicer selects.
Exercise 3 — Write a measure named Answer that returns total sales for all categories even when the matrix row is one category (remove the category filter only; keep other filters such as year).
Try it in real Power BI Desktop
- Filter context = the filters active when a measure is evaluated (slicer, row/column, axis, page filter, CALCULATE).
- A filter on a dimension flows to the fact table through the relationship.
- CALCULATE replaces the filter on the same column.
- REMOVEFILTERS removes a filter only when the question needs it.
Need a real Power BI dashboard for your business?
I design a data model and an executive dashboard fitted to your business and your real data.