All DAX Functions

The CALCULATE() Function: The Engine of DAX

Modify filter context and run aggregations under custom rules.

On this page

Overview

The CALCULATE function is the most powerful and fundamental function in Power BI DAX. It acts as the gateway to advanced data analysis because it allows you to modify or override the existing filter context of your report.

Think of it as a master controller: it evaluates a mathematical expression (like Sum, Average, or Count) but inside a newly defined set of custom rules/filters that you specify.

Syntax

DAX Syntax
CALCULATE(<expression>, <filter1>, <filter2>, ...)
  • <expression>: The mathematical aggregation you want to perform (e.g., SUM(Sales[Amount])).
  • <filter1>, <filter2>: The new conditions or rules you want to force upon that expression.

Example & Dataset

Imagine you have a basic retail sales table named Sales containing data for different regions and product categories:

Sample Data Table: Sales

OrderIDRegionCategoryAmount
101NorthElectronics500
102SouthElectronics300
103NorthFurniture700
104WestElectronics400
105NorthClothing200

The DAX Code

If you want to create a dedicated measure that only calculates sales for the North region, you write this:

North Region Sales Measure
North Region Sales =
CALCULATE(
    SUM(Sales[Amount]),
    Sales[Region] = "North"
)

Expected Output Visual

When you drag the native Category column and this new [North Region Sales] measure into a Table Visual, Power BI will generate this exact output:

Output Table Visual

CategoryStandard Total SalesNorth Region Sales
Clothing200200
Electronics1200500 (Only Order 101)
Furniture700700
Total21001400

Why Did This Output Happen?

Even though the first row of the visual asks for "Electronics" sales across the whole company ($1200), our CALCULATE measure steps in, hijacks the context, and filters down the data to look only at orders where the Region is North. Hence, it displays $500.