Sub topic 6
REMOVEFILTERS: clearing filters as a CALCULATE modifier
This chapter assumes you can write basic measures with SUM and COUNTROWS, and that you know how slicers and visuals filter a data model. It also assumes you have met CALCULATE and the idea of filter context from earlier chapters. Here you will learn what REMOVEFILTERS does, where it is valid, how it differs from ALL, and how to use it in measures.
What REMOVEFILTERS does
REMOVEFILTERS is a CALCULATE modifier. A modifier does not add a filter. It changes the filter context that CALCULATE has already received, by clearing filters from a table, from columns, or from the whole model.
The syntax is:
REMOVEFILTERS ( [<table> | <column> [, <column> [, ...]]] )The argument is optional. You can pass one of the following:
- A table name, which clears every filter on every column of that table.
- One or more column names, which clears filters only on those columns. All columns must come from the same table.
- Nothing, which clears every filter on every table in the model.
REMOVEFILTERS returns no value you can use. It is not a table expression. It only works as a filter argument of CALCULATE (or CALCULATETABLE), where it tells the engine to drop filters before the expression is evaluated.
Start with a base measure that reacts to filter context:
Total Sales = SUM ( Sales[Amount] )When this measure appears in a matrix with product categories on the rows, each row shows the sales of that category. The category on the row is a filter on 'Product'[Category]. Now clear that filter:
All Product Sales =
CALCULATE ( [Total Sales], REMOVEFILTERS ( 'Product' ) )Every row of the matrix now shows the same number: the sales of all products. Slicers on any column of 'Product', and groupings by any column of 'Product', no longer have an effect on this measure.
How the evaluation works
CALCULATE evaluates its filter arguments and modifiers first, then computes the expression in the resulting filter context. The order of steps matters when you combine several arguments.
- CALCULATE copies the current filter context, which comes from slicers, filters, rows, and columns of the visual.
- It applies the clearing modifiers, such as REMOVEFILTERS, to that copy.
- It then adds the new filters from boolean and table arguments.
- It evaluates the expression in the final filter context.
Because clearing happens before new filters are added, you can clear a table and add a filter on it in the same CALCULATE. The new filter survives:
Red Sales Ignoring Slicers =
CALCULATE (
[Total Sales],
REMOVEFILTERS ( 'Product' ),
'Product'[Color] = "Red"
)This measure returns the sales of red products, and ignores any other selection on 'Product', such as a slicer on Category or Brand. It differs from the plain boolean version, which only replaces the filter on Color:
Red Sales =
CALCULATE ( [Total Sales], 'Product'[Color] = "Red" )Red Sales keeps a Category slicer in place. If the user selects Category = "Audio", the measure returns the red audio products. Red Sales Ignoring Slicers returns all red products regardless of category.
Clearing a table, columns, or everything
The three forms of the argument give you three levels of control.
| Form | Effect | Typical use |
|---|---|---|
| `REMOVEFILTERS ( 'Product' )` | Clears all filters on every column of Product | Grand total across all products |
| `REMOVEFILTERS ( 'Product'[Color] )` | Clears the filter on Color only | Compare a color to all colors, but keep Category and Brand filters |
| `REMOVEFILTERS ()` | Clears all filters on all tables | Grand total of the whole model |
Clearing a single column is often the better choice. Suppose a report has a Category slicer and a Color grouping, and you want each color's share of the sales in the selected categories:
Sales % of All Colors =
DIVIDE (
[Total Sales],
CALCULATE ( [Total Sales], REMOVEFILTERS ( 'Product'[Color] ) )
)The denominator ignores the color on the row but still respects the Category slicer. If you had cleared the whole Product table, the denominator would ignore the slicer too, and the percentages would no longer add up to 100% within the slicer selection.
Column filters and relationships
A filter on a column of one table can reach another table through a relationship. Clearing filters on 'Product' removes filters that are applied directly to Product columns. It does not remove a filter that comes from another table, for example a filter on 'Date'[Year] that propagates to Sales.
To ignore the year as well, add a second modifier:
Sales Ignoring Product and Year =
CALCULATE (
[Total Sales],
REMOVEFILTERS ( 'Product' ),
REMOVEFILTERS ( 'Date'[Year] )
)Each modifier acts on its own table or columns. You can list as many as you need.
The percent-of-total pattern
The most common use of REMOVEFILTERS is the denominator of a ratio. The numerator keeps the current filters. The denominator clears them:
Sales % of All Products =
DIVIDE (
[Total Sales],
CALCULATE ( [Total Sales], REMOVEFILTERS ( 'Product' ) )
)On a row for a single product, the numerator is that product's sales and the denominator is the sales of all products. At the grand total row of the visual, both are equal, so the result is 100%.
DIVIDE returns a blank when the denominator is zero or blank, instead of raising an error. Prefer it over the / operator in ratios.
Be aware of what this measure ignores. A slicer on 'Product'[Category] does not change the denominator. If the user selects one category, the percentages show each product's share of all sales, and they will not add up to 100%. That is correct for "share of everything", but it may not be what the report reader expects. Chapter material on ALLSELECTED covers the "share of what is selected" variant.
REMOVEFILTERS compared with ALL
REMOVEFILTERS and ALL overlap. Inside CALCULATE, they have the same effect:
All Sales Using ALL =
CALCULATE ( [Total Sales], ALL ( 'Product' ) )This returns the same result as All Product Sales above. The difference is in what each function can do.
| Aspect | ALL | REMOVEFILTERS |
|---|---|---|
| Works as a CALCULATE modifier | Yes | Yes |
| Returns a table | Yes | No |
| Usable inside COUNTROWS, FILTER, iterators | Yes | No |
| Name states the intent | No, it can mean "give me all rows" | Yes, it only clears filters |
Use REMOVEFILTERS when you only want to clear filters. A reader who sees it knows at once that no table is being produced. Use ALL when you need the table, for example to count distinct categories regardless of the current filters:
Category Count = COUNTROWS ( ALL ( 'Product'[Category] ) )The version with REMOVEFILTERS fails, because REMOVEFILTERS does not return a table:
Category Count = COUNTROWS ( REMOVEFILTERS ( 'Product'[Category] ) ) -- errorCombining REMOVEFILTERS with other filter arguments
REMOVEFILTERS clears filters first, and then the other arguments add theirs. This ordering gives you a clean way to say "ignore what the user selected on this table, and use this condition instead".
You can also combine it with FILTER. The filtered table is computed in the context that results after clearing:
Large Line Sales All Products =
CALCULATE (
[Total Sales],
REMOVEFILTERS ( 'Product' ),
FILTER ( Sales, Sales[Quantity] * Sales[Net Price] > 1000 )
)The FILTER argument is itself evaluated in the original filter context of the CALCULATE, not in the cleared one. This is a subtle point. FILTER over Sales iterates only the sales rows that survive the visual's filters, including a Category slicer, and then CALCULATE applies the surviving rows as a filter on Sales. Because those rows are already limited to the slicer selection, the product filters you cleared are effectively re-applied through the rows that remain. If you need a truly unfiltered result, put the clearing inside the table expression, or filter a column in place of the whole table:
Large Line Sales All Products v2 =
CALCULATE (
[Total Sales],
CALCULATETABLE (
FILTER ( Sales, Sales[Quantity] * Sales[Net Price] > 1000 ),
REMOVEFILTERS ( 'Product' )
)
)Behavior in totals and with hierarchies
A measure that uses REMOVEFILTERS on a table returns the same value for every row and for the grand total of a visual that groups only by columns of that table. This is what you want for a denominator. It is rarely what you want for a final result, so a measure that returns only All Product Sales in a matrix looks flat and repetitive.
When a visual uses a hierarchy, such as Category above Subcategory, clearing 'Product'[Category] alone has two effects to keep in mind:
- The Subcategory rows remain filtered by their own column, so the denominator still depends on the subcategory.
- The row for each subcategory also carries the filter on Category from its parent level only if the visual passes it. A visual that shows both levels passes filters on both columns.
To make a denominator ignore the whole hierarchy, clear the table, or list each column.
Common mistakes
- Using REMOVEFILTERS where a table is required. It cannot be the argument of COUNTROWS, SUMX, or FILTER. Use ALL there.
- Clearing the whole table when one column is enough.
REMOVEFILTERS ( 'Product' )also discards slicers on unrelated Product columns, which can surprise the reader. Clear only the column you must. - Mixing columns from different tables in one call.
REMOVEFILTERS ( 'Product'[Color], 'Date'[Year] )is invalid. Write one call per table. - Expecting it to remove filters outside CALCULATE. A measure in a visual always has the filter context from the visual. Without CALCULATE, REMOVEFILTERS is not valid there.
- Forgetting about filters from other tables. Clearing Product does not clear a Date filter. Add a modifier for each table whose filter you want to ignore.
- Using it for a ratio and reading the totals wrongly. A denominator that ignores a slicer gives shares of the whole model, not of the selection.
Exercises
Exercise
A matrix shows Product[Category] on rows and a slicer on Date[Year]. You write Share = DIVIDE ( [Total Sales], CALCULATE ( [Total Sales], REMOVEFILTERS ( 'Product' ) ) ). The user selects Year = 2025. What does the denominator contain, and does the year selection affect it?
Show answer
The denominator is the sales of all products in 2025. REMOVEFILTERS ( 'Product' ) clears only filters on Product columns, so the filter from Date[Year] still reaches Sales through the relationship. The shares of the categories therefore add up to 100% within 2025.
Exercise
Why does Category Count = COUNTROWS ( REMOVEFILTERS ( 'Product'[Category] ) ) fail, and what is the correct version?
Show answer
REMOVEFILTERS does not return a table, so COUNTROWS has nothing to count. Use ALL, which returns the distinct categories while ignoring filters: Category Count = COUNTROWS ( ALL ( 'Product'[Category] ) ).
Exercise
Write a measure that returns the sales of the Color on the current row divided by the sales of all colors, while respecting a slicer on Product[Category].
Show answer
Sales % of All Colors = DIVIDE ( [Total Sales], CALCULATE ( [Total Sales], REMOVEFILTERS ( 'Product'[Color] ) ) ). Clearing only the Color column leaves the Category slicer active in the denominator.