If you learn only one DAX function properly, make it CALCULATE. Almost every useful Power BI measure uses it: sales for one region, last year's sales, percentage of total, sales from new customers. It is also the function that confuses beginners the most, because it does not just calculate. It changes the filters before it calculates.
This guide explains CALCULATE in plain language, with 10 practical examples, the rules you need to remember, and the mistakes that cause wrong results.
Quick answer:CALCULATE ( <expression>, <filter1>, <filter2>, … )evaluates the expression (usually a measure) after changing the filter context with the filters you give it. Example:Sales North = CALCULATE ( [Total Sales], Region[Region] = "North" ). A filter on a column replaces any existing filter on that column; useKEEPFILTERSto keep it, andALLorREMOVEFILTERSto remove filters.
Why CALCULATE matters: filter context in one minute
Every number in a Power BI visual is calculated with a set of filters, called the filter context. In a matrix with Region on rows and a Year slicer set to 2026, the cell for "North" is calculated with the filters Region = North and Year = 2026.
A normal measure such as SUM ( Sales[Amount] ) simply uses those filters. CALCULATE lets you change them: add a filter, replace one, or remove them all. That is why it can answer questions like "what were sales in North, whatever region is selected?" or "what share of the total is this row?"
CALCULATE syntax
CALCULATE (
<expression>,
<filter1>,
<filter2>,
…
)
- expression: what to calculate, usually a measure like
[Total Sales]. - filters: conditions such as
Region[Region] = "North", table expressions such asFILTER ( … ), or modifiers such asALL,REMOVEFILTERS,KEEPFILTERSandUSERELATIONSHIP.
All examples below use one base measure:
Total Sales = SUM ( Sales[Amount] )
10 CALCULATE examples you will actually use
1. Sales for one value
Sales North =
CALCULATE ( [Total Sales], Region[Region] = "North" )
Always shows North sales, even on a row for South. This is because a filter on Region[Region] replaces the row's filter on the same column.
2. Several conditions (AND)
Sales North Online =
CALCULATE (
[Total Sales],
Region[Region] = "North",
Sales[Channel] = "Online"
)
Separate filters are combined with AND.
3. OR on the same column
Sales North or South =
CALCULATE ( [Total Sales], Region[Region] IN { "North", "South" } )
IN is the cleanest way to write OR for one column. You can also write Region[Region] = "North" || Region[Region] = "South".
4. Percentage of grand total
% of Total =
DIVIDE (
[Total Sales],
CALCULATE ( [Total Sales], REMOVEFILTERS ( Region ) )
)
REMOVEFILTERS ( Region ) (or ALL ( Region )) removes the region filter for the denominator, so every row is divided by the total of all regions.
5. Percentage of the selected total
% of Selected =
DIVIDE (
[Total Sales],
CALCULATE ( [Total Sales], ALLSELECTED ( Region ) )
)
If the user selects only three regions in a slicer, the percentages add up to 100% across those three.
6. Keep the existing filter with KEEPFILTERS
Sales North (keep) =
CALCULATE ( [Total Sales], KEEPFILTERS ( Region[Region] = "North" ) )
Now the North row shows North sales and every other row shows blank, because the new filter is combined with the row's filter instead of replacing it.
7. Condition on a measure (with FILTER)
Sales from Big Customers =
CALCULATE (
[Total Sales],
FILTER ( VALUES ( Customer[Customer] ), [Total Sales] > 1000 )
)
A simple Boolean filter cannot use a measure, so iterate over the customer list with FILTER and test the measure for each customer. Use a small dimension column such as VALUES ( Customer[Customer] ), not the whole Sales table.
8. Year-to-date and last year
Sales YTD =
CALCULATE ( [Total Sales], DATESYTD ( 'Date'[Date] ) )
Sales LY =
CALCULATE ( [Total Sales], SAMEPERIODLASTYEAR ( 'Date'[Date] ) )
Time intelligence functions return a table of dates, and CALCULATE uses it as a filter. More examples are in Time Intelligence in Power BI: DATEADD and SAMEPERIODLASTYEAR.
9. Use an inactive relationship
Sales by Ship Date =
CALCULATE (
[Total Sales],
USERELATIONSHIP ( Sales[ShipDate], 'Date'[Date] )
)
If your Sales table has both an order date and a ship date, only one relationship to the Date table can be active. USERELATIONSHIP activates the other one for this measure only.
10. Running total
Running Total =
CALCULATE (
[Total Sales],
FILTER (
ALLSELECTED ( 'Date'[Date] ),
'Date'[Date] <= MAX ( 'Date'[Date] )
)
)
Remove the date filter, then keep every date up to the current one. Four methods are explained in Running Total in Power BI.
The 4 rules of CALCULATE
- Filters on a column replace existing filters on that column.
Region[Region] = "North"overrides a slicer or row filter on Region. Wrap it inKEEPFILTERSto combine instead. - Filters on different columns are combined (AND). A filter on Region does not remove a filter on Year.
- Boolean filters cannot reference measures.
[Total Sales] > 1000must go insideFILTERover a table, as in example 7. - CALCULATE performs context transition. Inside a row context (a calculated column or an iterator such as
SUMX), CALCULATE turns the current row into a filter. That is whySUMX ( VALUES ( Customer[Customer] ), [Total Sales] )calculates sales per customer: every measure reference has a hidden CALCULATE around it.
CALCULATE vs FILTER vs CALCULATETABLE
| Function | Returns | Use it for |
|---|---|---|
| CALCULATE | A single value | Measures with changed filters |
| CALCULATETABLE | A table | The same filter changes, when you need a table (for example inside another function) |
| FILTER | A table | Row-by-row conditions, often as an argument of CALCULATE |
Learn FILTER in How to Use FILTER in DAX, and the filter-removing functions in ALL and ALLEXCEPT in DAX.
Common mistakes with CALCULATE
Using FILTER on the whole fact table
CALCULATE ( [Total Sales], FILTER ( Sales, Sales[Channel] = "Online" ) ) gives the right answer but scans every sales row and can be slow. Write Sales[Channel] = "Online" instead; DAX turns it into an efficient column filter.
Expecting a filter to "add" to a slicer
If a slicer selects South and your measure says Region[Region] = "North", the result is North, not blank. That surprises many people. Use KEEPFILTERS if you want the intersection.
Using CALCULATE in calculated columns without thinking about context transition
In a calculated column, CALCULATE ( SUM ( Sales[Amount] ) ) filters by every column of the current row, which can give unexpected numbers and even circular dependency errors. See Calculated Columns vs Measures.
Wrong totals with conditional logic
A measure like IF ( [Total Sales] > 1000, … ) is checked once at the total row, not per row. Fix it with SUMX over the right column, as explained in Power BI Total Wrong? How to Fix Incorrect DAX Totals.
Frequently asked questions
What does CALCULATE do in DAX?
It evaluates an expression in a modified filter context. You add, replace or remove filters, and CALCULATE computes the expression under those new filters.
Can CALCULATE have multiple filters?
Yes. Add as many filter arguments as you need. Filters on different columns are combined with AND.
What is the difference between ALL and REMOVEFILTERS?
Inside CALCULATE they do the same thing: remove filters. REMOVEFILTERS is clearer to read. ALL can also be used as a table function outside CALCULATE.
Why does my CALCULATE measure ignore the slicer?
Because a filter argument on the same column replaces the slicer's filter. Wrap the filter in KEEPFILTERS to respect the slicer.
Can I use a measure inside a CALCULATE filter?
Not in a simple Boolean filter. Use FILTER ( VALUES ( Table[Column] ), [Measure] > value ) as the filter argument.
Keep learning
CALCULATE is the heart of DAX. Practise these 10 examples in your own report, follow the full Free Power BI Course, and keep the Power BI DAX Cheat Sheet open while you work.
Which CALCULATE pattern do you use most? If a measure gives a strange result, share it in the comments and I will help you fix it.
