11.5KEEPFILTERS
As you have seen, a filter of CALCULATE replaces the existing filter on the same column. Sometimes you will want to keep both instead. KEEPFILTERS changes this rule. With it, the new filter is added to the old one.
Your manager wants, for example, a table visual by city that only shows the US cities, each with its own figure.
11.5.1Adding instead of replacing
KEEPFILTERS is written around a filter of CALCULATE. Without it, this filter takes the place of the filter the visual already sets on the same column. With it, the filter is added to the filters already set, and only the rows that meet both are kept.
In our data, let’s go back to the “New York Revenue” measure, which returned 900,000 on every row of a table visual by city. Let’s wrap its condition in KEEPFILTERS:
“I want the revenue of New York, keeping what is already shown instead of replacing it.”
| City | New York Revenue Kept |
|---|---|
| New York | 900,000 |
| Total | 900,000 |
This is a reproduction of the Power BI interface for teaching purposes. It differs from the real interface.
On the Chicago row, the Chicago filter stays in place, and the New York filter is added to it. No customer is in Chicago and in New York at the same time. The measure is blank, and Power BI hides the row. Only the New York row keeps a result.
The rest of this lesson is part of izyDAX Pro
You have just read the first section. The next 2, their animations, the exercises and the summary are waiting for you with izyDAX Pro, in a single payment.