Sub topic 3
How Filters Change a Measure's Result
This chapter assumes you can work in Power BI Desktop's Report view, that your model has a Sales table with a numeric SalesAmount column, and that you know what tables, columns, and rows are. It also assumes you have created at least one measure.
One formula, many answers
A measure is a formula that Power BI evaluates on demand. It does not store one fixed number. Every time a visual, slicer, or filter changes, the measure runs again and returns a new result.
Take this measure:
Total Sales = SUM(Sales[SalesAmount])You write it once. Yet in a report it can show $2.4M on a card, $310K for one bar in a chart, and $18K in one cell of a matrix. The formula is the same each time. What differs is which rows of Sales the formula is allowed to see.
What filter context is
Filter context is the set of filters that apply to a measure at the moment it is calculated. Power BI builds it automatically from things on the report page:
- The fields on a visual's axis, legend, rows, or columns.
- Slicers.
- Filters in the Filters pane (visual level, page level, and report level).
- Other visuals, when you cross-filter by clicking a bar or a data point.
Once the filter context narrows the data, SUM adds up only the remaining rows. You never write the filtering in the formula. The report supplies it.
Following one measure through a report
Suppose the Sales table has these rows.
| Region | Year | SalesAmount |
|---|---|---|
| East | 2024 | 100 |
| East | 2025 | 150 |
| West | 2024 | 200 |
| West | 2025 | 250 |
Here is what Total Sales returns in different places.
| Where the measure appears | Filter context | Result |
|---|---|---|
| Card with no filters | None | 700 |
| Card with a slicer set to 2025 | Year = 2025 | 400 |
| Bar for East in a chart by Region | Region = East | 250 |
| Bar for East, with the 2025 slicer on | Region = East and Year = 2025 | 150 |
Each row of the table is the same calculation under a different filter context. Filters combine. When a bar and a slicer both apply, a row must satisfy both to be counted.
Seeing it for yourself
You can check this behavior in a few steps.
- Create the
Total Salesmeasure above. - Add a card visual and put
Total Salesin it. Note the number. - Add a table visual with a region or product column and
Total Salesas a value. Each row shows a different total, and the grand total row matches the card. - Add a slicer on a year or category column. Select a value and watch both visuals change.
- Click a bar or row in one visual. Other visuals on the page recalculate, because the click acts as a filter.
The measure is never edited during this exercise. Only the filter context changes.
Measures versus calculated columns
This behavior is the main reason to prefer measures for totals. A calculated column is computed once, row by row, when the data is refreshed. Its values are stored and do not respond to slicers. A measure is computed at report time, so it always reflects the current filters.
Common errors
- Expecting the same number everywhere. If a total looks "wrong" in a visual, check which slicers, page filters, and cross-filtering are active. The measure is usually correct for its filter context.
- Forgetting that the grand total is also filtered. The total row of a table is the measure evaluated with no row-level filter from that table. It still respects slicers and the Filters pane.
- Filtering on a column from an unrelated table. If a slicer's table has no relationship to
Sales, it cannot narrow theSalesrows, and the measure will not change. Check the model relationships. - Putting a column from
Saleson a visual instead of using a measure. DraggingSalesAmountstraight onto a visual creates an implicit aggregation, not a measure you control. A later chapter covers why explicit measures are better.
Exercise
A card shows Total Sales of 700 for the table above. You add a slicer on Region and select West, then also select Year 2024 in a second slicer. What does the card show, and why?
Show answer
It shows 200. The two slicers combine into one filter context (Region = West and Year = 2024). Only one row matches both, the West 2024 row with SalesAmount 200. The formula SUM(Sales[SalesAmount]) did not change.