11.1Introduction to filter modifiers
This lesson opens the step devoted to filter modifiers. It explains what the term means, then shows why the table given to a function matters. Each modifier is covered in detail later in this step.
11.1.1Filter modifiers
Inside CALCULATE, functions like ALL, ALLSELECTED, ALLEXCEPT, ALLNOBLANKROW, REMOVEFILTERS and KEEPFILTERS are called filter modifiers. The first four each build a virtual table, that is, a table DAX builds for the time of the calculation and that does not exist in the model. CALCULATE uses it to change the filters of the calculation.
REMOVEFILTERS and KEEPFILTERS are filter modifiers too, but they build no table. They tell CALCULATE directly how to handle the filters.
The content of this table depends on the arguments of the function and on the evaluation context, that is, the filters that apply where the calculation happens, for example a row of a visual or a slicer.
Technically, “ALL is a filter modifier” is a shortcut. ALL is a filter modifier when you place it in the filters of CALCULATE.
Here are the six functions, one row each, with their uses. The last two have no table use, which means you cannot use them as a table, since they build none.
| Function | As a filter modifier in CALCULATE | As a table expression | Main nuance |
|---|---|---|---|
| ALL | CALCULATE uses it to replace the filters of the column or table named. | All the values of a column, or all the rows of a table, regardless of the filters. | It keeps the blank row that DAX adds when a relationship contains values with no match. |
| ALLSELECTED | CALCULATE uses it to get back only the filters set outside the visual. | The values let through by the filters set outside the visual, like a slicer. | Its result depends on the context of the visual. It does not take the filters of the row into account. |
| ALLEXCEPT | CALCULATE uses it to replace the filters of all the other columns of the table. | The rows of a table, keeping only the filters of the columns named. | Its first argument is a table, followed by the columns whose filters are kept. |
| ALLNOBLANKROW | Same role as ALL, without the blank row. | Like ALL, but without the blank row added by DAX. | The difference with ALL only shows if a relationship contains values with no match. |
| REMOVEFILTERS | Asks CALCULATE to remove the filters of the column or table named. | None. It builds no table. | It is only written in the filters of CALCULATE or CALCULATETABLE, where it plays the same role as ALL. |
| KEEPFILTERS | Asks CALCULATE to keep the filters already set and to add the filter of its argument to them, instead of replacing them with it. | None. It builds no table. | It wraps a filter of CALCULATE so that it is added to the existing filters. |
The rest of this lesson is part of izyDAX Pro
You have just read the first section. The next 4, their animations, the exercises and the summary are waiting for you with izyDAX Pro, in a single payment.