Short answer: ALLSELECTED removes the filters that come from the rows and columns of the visual but keeps the filters from outside: slicers, page and report filters, cross-filtering from other visuals. Inside CALCULATE it gives "the total of what the reader selected", so a share adds to 100% within the visual. With a column (ALLSELECTED ( 'Product'[Product] )) it also returns the selected values as a table, for ranks and averages over the selection.
ALL gives the share of everything that exists. Readers who pick three products in a slicer expect the three shares to add up to 100%. That is ALLSELECTED.
How do ALL and ALLSELECTED differ?
% of All = DIVIDE ( [Revenue], CALCULATE ( [Revenue], ALL ( 'Product' ) ) )
% of Selected = DIVIDE ( [Revenue], CALCULATE ( [Revenue], ALLSELECTED ( 'Product' ) ) )| Product | Revenue | % of All | % of Selected |
|---|---|---|---|
| Mountain-200 | 900 | 31% | 37% |
| Road-150 | 1,200 | 41% | 50% |
| Bottle | 320 | 11% | 13% |
| Total | 2,420 | 83% | 100% |
All products together make 2,920. % of All divides by 2,920; % of Selected by the 2,420 the slicer left.
What does Microsoft say it keeps?
From the reference: ALLSELECTED "retains all filters explicitly set within the query, and it retains all context filters other than row and column filters". With one argument it takes a table or a column; with more, columns of the same table. Without arguments, ALLSELECTED ( ) removes the row and column filters of every table, for the grand total of the visual.
Which other measures use the selection?
-- rank among the selected products
Rank in Selection = RANKX ( ALLSELECTED ( 'Product'[Product] ), [Revenue] )
-- average of the selected months
Avg Selected Month = AVERAGEX ( ALLSELECTED ( 'Date'[Month] ), [Revenue] )
-- running total over the selected dates
Running Revenue =
CALCULATE (
[Revenue],
FILTER (
ALLSELECTED ( 'Date'[Date] ),
'Date'[Date] <= MAX ( 'Date'[Date] )
)
)The running total starts at the first date in the date slicer, not at the first date in the model.
Where does ALLSELECTED surprise?
ALLSELECTED restores the filter context that was active outside the visual's iteration (the "shadow" filter context). Microsoft's reference describes it as above, and it behaves predictably in measures placed directly in visuals. It gets hard to reason about when:
- it is used inside an iterator (
SUMXwithALLSELECTEDinside the expression), or - a measure with
ALLSELECTEDis called from another measure that iterates.
In those cases the "outer" context may be the iterator's, not the slicers'. Keep ALLSELECTED in top-level measures, and for complex cases use visual calculations (COLLAPSEALL), which refer to the visual's structure directly.
What goes wrong?
- Using it in calculated columns. There is no visual or slicer at refresh; and in DirectQuery it is not supported in calculated columns or RLS rules.
- ALLSELECTED on the wrong table.
ALLSELECTED ( 'Product' )restores product filters only; a region on the rows still filters. - Nesting in iterators. Results change in ways that are hard to follow; restructure.
- Expecting slicers to be removed. They stay; use
ALLorREMOVEFILTERSto ignore them.
Where can you check this?
- Microsoft Learn: ALLSELECTED function (DAX)
- Microsoft Learn: ALL function (DAX)
- Microsoft Learn: RANKX function (DAX)
Where do you start?
Put % of All and % of Selected side by side in a table with a product slicer, and select a few products. ALL, ALLEXCEPT and REMOVEFILTERS covers removing every filter.