(+351) 21 24 10006  ·  info@bconcepts.pt
Carnaxide, Lisbon
CALCULATE in DAX: the function that changes filter context
Power BI

CALCULATE in DAX: the function that changes filter context

Equipa bConcepts 22/07/2025 2 min

If one function separates people who dabble in DAX from those who truly master it, it is CALCULATE. It is the most powerful function in the language — the one that answers questions like "how much did we sell in the North region only?" or "what is the percentage of the total?". Understanding CALCULATE is understanding DAX.

What makes CALCULATE special

Almost every DAX function reads the filter context; CALCULATE is the only one that modifies it. It evaluates an expression (usually a measure) after applying the filters you specify. That power to change the context is what makes it central.

CALCULATE in DAX: the function that changes filter context

The syntax, no mystery

The form is CALCULATE( expression, filter1, filter2, ... ). The first argument is what you want to compute; the rest are the conditions to apply. For example, CALCULATE( [Total Sales], Region[Name] = "North" ) returns sales for the North only, regardless of what is selected on the page.

Replacing vs adding filters

  • By default, CALCULATE replaces the existing filter on the column you mention — if the page filters "South" and CALCULATE asks for "North", North wins.
  • To preserve context, use KEEPFILTERS when you want to intersect rather than override.
  • REMOVEFILTERS/ALL strip filters — essential for percentage-of-total calculations.

The most useful pattern: percentage of total

One of the most common uses is DIVIDE( [Total Sales], CALCULATE( [Total Sales], ALL(Product) ) ): the numerator respects the context (the row's product), the denominator removes it (all products), giving each product's share. That is CALCULATE changing the context to create the reference total.

Mistakes to avoid

The classic error is expecting CALCULATE to sum across rows like an aggregation function — that is not what it does. It adjusts the context and delegates the calculation to the measure. Think of it as "compute this, but first change the filter to...".

In practice

Master CALCULATE with simple filters, then explore ALL, KEEPFILTERS and variables. It is the step that turns basic reports into truly flexible analysis. Which question in your report would you solve today if you could change the filter context at will?

← Back to insights
Let's talk?

Ready to transform your data?

Book a free 30-minute meeting and find out how we can help your team make better decisions.

Book a Free Meeting
bConcepts