Short answer: these functions remove filters. REMOVEFILTERS only removes filters, inside CALCULATE: from a table, from columns, or from everything. ALL does the same as a CALCULATE modifier, and can also return a table of all rows or all distinct values, ignoring filters, which you can iterate or count. ALLEXCEPT ( table, col1, ... ) removes all filters from a table except those on the listed columns. ALLNOBLANKROW is like ALL without the blank row that unmatched keys add. Microsoft recommends REMOVEFILTERS when you only want to remove filters.
"Percent of total" is the first measure most people write after a sum, and it needs one of these: the total is the same revenue with the filters removed.
What does each function do?
| Function | As CALCULATE modifier | As table function |
|---|---|---|
| REMOVEFILTERS ( table or columns ) | removes those filters | not available |
| REMOVEFILTERS ( ) | removes all filters | not available |
| ALL ( table ) | removes all filters on the table | all rows of the table |
| ALL ( col1, col2 ) | removes filters on these columns | distinct combinations of these columns |
| ALLEXCEPT ( table, cols ) | removes all filters on the table except on cols | all rows, keeping those filters |
| ALLNOBLANKROW ( table or cols ) | as ALL, without the blank row | rows without the blank row |
How do you calculate shares?
-- percent of all products, whatever is filtered on Product
% of All Products =
DIVIDE ( [Revenue], CALCULATE ( [Revenue], REMOVEFILTERS ( 'Product' ) ) )
-- percent of the category (parent): remove the product filter, keep category
% of Category =
DIVIDE (
[Revenue],
CALCULATE ( [Revenue], REMOVEFILTERS ( 'Product'[Product] ) )
)
-- the same with ALLEXCEPT
% of Category 2 =
DIVIDE (
[Revenue],
CALCULATE ( [Revenue], ALLEXCEPT ( 'Product', 'Product'[Category] ) )
)| Category, Product | Revenue | % of All Products | % of Category |
|---|---|---|---|
| Bikes, Mountain-200 | 900 | 31% | 43% |
| Bikes, Road-150 | 1,200 | 41% | 57% |
| Accessories, Helmet | 500 | 17% | 61% |
| Accessories, Bottle | 320 | 11% | 39% |
| Total | 2,920 | 100% | 100% |
Filters from other tables (year, region) stay in place in all three measures. REMOVEFILTERS ( 'Product'[Product] ) keeps other Product columns, such as a Color slicer, while ALLEXCEPT ( 'Product', 'Product'[Category] ) removes the Color filter too.
When do you need ALL as a table?
-- number of products, whatever is filtered
Product Count All = COUNTROWS ( ALL ( 'Product' ) )
-- rank among all products, not just the visible ones
Product Rank = RANKX ( ALL ( 'Product'[Product] ), [Revenue] )
-- average monthly revenue across all months of the year in context
Avg Month = AVERAGEX ( ALL ( 'Date'[Month] ), [Revenue] )REMOVEFILTERS cannot be used here: it does not return a table.
What is the blank row?
When a fact table holds keys missing from a dimension, the dimension gets a virtual blank row that collects them. ALL ( 'Product' ) includes it; ALLNOBLANKROW ( 'Product' ) does not. COUNTROWS ( ALL ( 'Product' ) ) can therefore be one more than the real number of products.
What goes wrong?
- ALLEXCEPT on the fact table.
ALLEXCEPT ( Sales, 'Product'[Category] )removes the filters of every table that filters Sales (dates, customers, regions) except the listed column, which is rarely the intent; useREMOVEFILTERSon the dimension columns you want gone. - ALLEXCEPT removes more than expected. It also removes filters on columns you forgot to list, such as Color.
- ALL ( Sales ) in a measure. Removing filters from the fact table removes the effect of all dimension filters for that calculation; usually you want
REMOVEFILTERSon one dimension. - Ignoring slicers.
% of All Productsignores a product slicer too; use ALLSELECTED for "of what the reader selected".
Where can you check this?
- Microsoft Learn: ALL function (DAX)
- Microsoft Learn: ALLEXCEPT function (DAX)
- Microsoft Learn: REMOVEFILTERS function (DAX)
Where do you start?
Write % of All Products and % of Category and put them in a matrix by category and product. ALLSELECTED covers the share of what the reader selected.