CALCULATE

CALCULATE is the most important function in DAX. It evaluates an expression with changed filters: only hardware, only 2026, always the North region. Almost every KPI that goes beyond a sum uses it.

In short: CALCULATE(expression, filter1, filter2, …) takes the cell's filter context, changes it by the given filters and then evaluates the expression. A filter on a column replaces the existing filter on exactly that column; filters on other columns stay.

Before this: Filter context.

Try it now

Task Create the measure "Hardware Sales": [Total Sales], but only for the Hardware category.

Sales 120 rows, 7 columns
OrderIDOrderDateShipDateProductIDRegionIDQuantityAmount
13 Oct 20266 Oct 20261221798
29 Nov 202519 Nov 20252351145
320 Sep 202627 Sep 2026544596
416 Jun 20252 Jul 20252151145
526 Mar 202631 Mar 20261343596
64 Dec 202510 Dec 2025545745
78 Jul 202526 Jul 2025614196
820 Feb 20251 Mar 202532359.7
99 Dec 202524 Dec 202562298
1012 Aug 202625 Aug 2026212458
117 Sep 202612 Sep 2026542298
122 Mar 202614 Mar 2026623147

Showing the first 12 of 120 rows.

Measures: [Total Sales]

Product 6 rows, 4 columns
ProductIDProductCategoryPrice
1LaptopHardware899
2MonitorHardware229
3MouseAccessories19.9
4KeyboardAccessories39.9
5Office suiteSoftware149
6AntivirusSoftware49
Region 4 rows, 2 columns
RegionIDRegion
1North
2South
3West
4East
Date 730 rows, 4 columns
DateYearMonthMonthName
1 Jan 202520251Jan
2 Jan 202520251Jan
3 Jan 202520251Jan
4 Jan 202520251Jan
5 Jan 202520251Jan
6 Jan 202520251Jan
7 Jan 202520251Jan
8 Jan 202520251Jan
9 Jan 202520251Jan
10 Jan 202520251Jan
11 Jan 202520251Jan
12 Jan 202520251Jan

Showing the first 12 of 730 rows.

How CALCULATE works

  1. Power BI takes the cell's filters, for example Region = South.
  2. CALCULATE adds the filters from its arguments, for example Category = Hardware.
  3. With these filters it evaluates the expression, here [Total Sales]: hardware sales in the South.

Several filters in CALCULATE apply at the same time (AND). A filter like Product[Category] = "Hardware" always refers to exactly one column.

A filter on the same column replaces

If the column CALCULATE filters is already in the matrix rows, CALCULATE wins: the row's filter on that column is replaced. That is intended, for example for a benchmark that stays the same in every row.

Task As a benchmark, every row should show the sales of the North region. Create the measure "North Sales" and look at what happens in the rows of the other regions.

Sales 120 rows, 7 columns
OrderIDOrderDateShipDateProductIDRegionIDQuantityAmount
13 Oct 20266 Oct 20261221798
29 Nov 202519 Nov 20252351145
320 Sep 202627 Sep 2026544596
416 Jun 20252 Jul 20252151145
526 Mar 202631 Mar 20261343596
64 Dec 202510 Dec 2025545745
78 Jul 202526 Jul 2025614196
820 Feb 20251 Mar 202532359.7
99 Dec 202524 Dec 202562298
1012 Aug 202625 Aug 2026212458
117 Sep 202612 Sep 2026542298
122 Mar 202614 Mar 2026623147

Showing the first 12 of 120 rows.

Measures: [Total Sales]

Product 6 rows, 4 columns
ProductIDProductCategoryPrice
1LaptopHardware899
2MonitorHardware229
3MouseAccessories19.9
4KeyboardAccessories39.9
5Office suiteSoftware149
6AntivirusSoftware49
Region 4 rows, 2 columns
RegionIDRegion
1North
2South
3West
4East
Date 730 rows, 4 columns
DateYearMonthMonthName
1 Jan 202520251Jan
2 Jan 202520251Jan
3 Jan 202520251Jan
4 Jan 202520251Jan
5 Jan 202520251Jan
6 Jan 202520251Jan
7 Jan 202520251Jan
8 Jan 202520251Jan
9 Jan 202520251Jan
10 Jan 202520251Jan
11 Jan 202520251Jan
12 Jan 202520251Jan

Showing the first 12 of 730 rows.

This exercise is part of Premium.

Premium unlocks every exercise in every lesson, unlimited practice with fresh tasks and the final test with certificate.

See Premium Already Premium? Log in

The first exercise in this lesson is free.

To keep the row's filter, wrap the filter in KEEPFILTERS: CALCULATE([Total Sales], KEEPFILTERS(Region[Region] = "North")). Then only the North row shows a value, all others stay blank.

CALCULATE and SUMIF

ExcelDAX
=SUMIF(C:C, "Hardware", F:F)CALCULATE(SUM(Sales[Amount]), Product[Category] = "Hardware")
=COUNTIFS(…)CALCULATE(COUNTROWS(Sales), …)

The difference: SUMIF needs the category in the same table. CALCULATE filters through the relationship, so the category can live in the Product table.

In real Power BI

  1. New measure: Hardware Sales = CALCULATE([Total Sales], Product[Category] = "Hardware").
  2. Put it in a matrix with Region in the rows, next to [Total Sales] for comparison.

Common mistakes

Text without quotes, numbers with

Text needs double quotes, numbers do not: 'Date'[Year] = 2026, not "2026". Otherwise Power BI reports that text and numbers cannot be compared.

A measure as a filter

CALCULATE([Total Sales], [Total Sales] > 1000) does not work: a simple filter needs a column. Conditions on measures use FILTER, which comes in level 5.

FAQ

How do I remove a filter?

With REMOVEFILTERS or ALL as a filter argument, for example for a share of the total. That is a topic of level 5.

Can I allow several values?

Yes, with IN: Region[Region] IN {"North", "South"}, or with OR conditions on the same column: Region[Region] = "North" || Region[Region] = "South".

Up next: variables with VAR

Making long formulas readable and calculating intermediate results only once.

Next lesson

Write to us

Choose language

Select your preferred language