CALCULATE — The Most Important DAX Function
Master CALCULATE to control filter context and build any business metric in Power BI
CALCULATE is the most important function in DAX. Almost every non-trivial DAX measure uses CALCULATE. It does one thing: evaluates an expression while modifying the filter context.
In plain English: CALCULATE lets you answer questions like "What were sales in Delhi, regardless of what region is selected in the slicer?" or "What were sales in the previous year?" or "What is the sales for only Category = Electronics?"
Every time you want to override or add to the current filter — you use CALCULATE.
How CALCULATE Modifies Filter Context
SUM(Sales[Amount])
Active filters (from slicer):
Region = Delhi ✓
Result: Delhi sales only
₹2,50,000
⚡
CALCULATE(SUM(...), ALL(Region))
Active filters (modified):
Region filter removed
Result: ALL regions
₹10,00,000
Common CALCULATE patterns
% of Total
CALCULATE(SUM(...), ALL(table))
Filter by value
CALCULATE(SUM(...), Region = "Delhi")
Last year
CALCULATE(SUM(...), SAMEPERIODLASTYEAR(...))
Remove filter
CALCULATE(SUM(...), ALL(column))
Syntax
CALCULATE(expression, filter1, filter2, ...) expression — any DAX measure or aggregation filter1... — one or more filter conditions that modify context
Examples
Key Points
- ✓CALCULATE is how you write conditional aggregations in DAX
- ✓Filters in CALCULATE add to or replace existing filter context
- ✓ALL() removes all filters from a table — used for "% of total" calculations
- ✓CALCULATE with a boolean filter: CALCULATE(SUM(...), Table[Col] = "Value")
- ✓Nested CALCULATE is allowed — outer filter context takes precedence
Common Mistakes
Practice Question
You want a measure that always shows total sales across ALL regions, regardless of which region is selected in a slicer. Which formula is correct?