(+351) 21 24 10006  ·  info@bconcepts.pt
Carnaxide, Lisbon
DAX

CALCULATE in DAX: the engine behind every advanced measure

João Barros 03 de December de 2024 2 min read

CALCULATE is considered the most powerful and fundamental DAX function. Practically every non-trivial measure depends on it. Its job is simple but its impact is profound: evaluate an expression in a modified filter context.

Syntax

CALCULATE(
    <Expression>,
    <Filter1>,
    <Filter2>,
    ...
)

Basic example

Lisbon Sales = CALCULATE(
    SUM(fSales[Revenue]),
    dRegion[City] = "Lisbon"
)

Even if the report is filtered by another city, this measure always shows Lisbon sales.

CALCULATE with REMOVEFILTERS

% of Total = DIVIDE(
    SUM(fSales[Revenue]),
    CALCULATE(SUM(fSales[Revenue]), REMOVEFILTERS(dRegion))
)

REMOVEFILTERS removes the region dimension filter, allowing the percentage to be calculated over the total regardless of the filter applied in the visual.

CALCULATE with ALL, ALLEXCEPT, ALLSELECTED

  • ALL(table) — removes all filters from the table.
  • ALLEXCEPT(table, column) — removes all filters except the specified column.
  • ALLSELECTED() — removes internal filters but preserves the user's (slicers/cross-filter).

CALCULATE and context transition

When CALCULATE is called inside an iterator (such as SUMX), it converts the row context into a filter context — each row of the iteration filters the table before evaluating the expression.

Conclusion

CALCULATE is not just a function — it is the mechanism by which DAX manipulates the evaluation context. Mastering it opens the door to time intelligence measures, comparative analysis, dynamic rankings and much more.

Share: