TECHNOLOGIESTieInn Technologies

CALCULATE and filter context

Power BI · 12 questions

Short notes

Key idea

Every measure is evaluated in a filter context: the filters from the visual's row, slicers and page filters. CALCULATE changes that context: it adds, replaces or removes filters before evaluating.

Syntax

Chennai Revenue = CALCULATE([Revenue], Customers[City] = "Chennai")
All Cities Revenue = CALCULATE([Revenue], ALL(Customers[City]))
Share of Total = DIVIDE([Revenue], [All Cities Revenue])
Paid Revenue = CALCULATE([Revenue], KEEPFILTERS(Orders[Status] = "Paid"))

Example

In a table by city, Share of Total shows each city's revenue divided by revenue across all cities. ALL removes the city filter only for the denominator, so each row keeps its own numerator.

Traps

  • A filter argument replaces the existing filter on that column, it doesn't intersect with it. Use KEEPFILTERS to intersect.
  • ALL(Table) removes every filter on the table; ALL(Table[Col]) only that column.
  • Row context isn't filter context. In a calculated column, wrap a measure in CALCULATE (context transition) to filter by the current row.
  • Test a measure in a simple table with the grand total visible.

Want the full lesson with step-by-step examples, a project and a certificate? Power BI course, ₹120 →

Questions

5 free questions
5 questions

    CALCULATE and filter context

  1. Question 1easy

    What does CALCULATE do?

  2. CALCULATE and filter context

  3. Question 2hard

    A table visual has orders[status] on rows. In the "pending" row, what does this measure show?

    Delivered Revenue = CALCULATE([Total Revenue], orders[status] = "delivered")
  4. CALCULATE and filter context

  5. Question 3medium

    Which measure gives each city's share of revenue across all cities, in a visual with city on rows?

  6. CALCULATE and filter context

  7. Question 4medium

    A page slicer is set to year 2024. A measure uses REMOVEFILTERS(customers[city]). Is the year still applied?

  8. CALCULATE and filter context

  9. Question 5easy

    A table visual has customers[city] on rows and [Total Revenue]. How does the measure show a different value for each city?

7 more questions on this topic, with hints, and tests

Sign up free for 21 days of every question and test.