Stop 08 · Filter Context & CALCULATETopics · 6/9

ALLSELECTED and Visual Totals

Part of the Power BI Roadmap

In short

A user picks three categories in a slicer and expects each to show a share of those three, adding up to 100%. ALL gives shares of everything. ALLSELECTED gives shares of what the user selected.

ALLSELECTED removes filters coming from the visual's own rows and columns but keeps outside filters like slicers, so it gives the total the user can currently see.

The jaadu sits at a small table with three pizzas, carefully dividing slices among friends while many more pizza boxes stay stacked on the shop counter behind.

Think of it like this

Sharing out the pizzas on the table

A pizza shop made ten pizzas today, but only three are on your table. When friends ask "what share did I eat?", they mean of these three, not of the shop's ten. ALLSELECTED measures against the pizzas on the table: what the slicers allowed.

Watch it happen

Slicer keeps 3 of 5 categories

Snacks 40k
0
Dairy 30k
1
Beverages 30k
2

1/4The slicer keeps Snacks, Dairy and Beverages. Two other categories are hidden. All five total 200k.

The big ideas

What you need to know

Keeps outside filters

ALLSELECTED removes filters coming from the visual's own rows and columns but keeps slicers and filter pane filters.

Totals are recalculated

A total row isn't the sum of the rows above. It's the measure evaluated again with the row filter removed.

Visible-share %

DIVIDE ( [Total Sales], CALCULATE ( [Total Sales], ALLSELECTED ( 'Product'[Category] ) ) ).

Use it in measures for visuals

ALLSELECTED depends on the visual. In complex iterators its result can surprise you, so keep it simple.

See it in code

Walk through the code

dax
1% of All Categories =2DIVIDE (3    [Total Sales],4    CALCULATE ( [Total Sales], REMOVEFILTERS ( 'Product'[Category] ) )5)6 7% of Selected Categories =8DIVIDE (9    [Total Sales],10    CALCULATE ( [Total Sales], ALLSELECTED ( 'Product'[Category] ) )11)

1/3The denominator ignores every Category filter, including the slicer, so shares are of all categories.

Show both in a table by category with a Category slicer. Only the second adds up to 100% for the visible rows.

Save yourself the pain

Common mistakes

Oops

Using ALL for a share that users expect to add up to 100% after slicing.

Do this instead

Use ALLSELECTED so the denominator respects the slicer.

Oops

Expecting a total row to add up the rows of a measure with IF or MAX logic.

Do this instead

Totals re-run the measure at total level. Use SUMX over the row values if you need a true sum.

Your mission

Two kinds of share

~20 min

Quick check

A Region slicer is set to South. In a table by category, which denominator gives the share of South's total sales?

Go deeper

  1. 1Build % of Visible Total with ALLSELECTED and compare it with REMOVEFILTERS.
  2. 2Change a slicer and watch which measure still adds up to 100%.
  3. 3Use ALLSELECTED mainly in measures shown inside visuals.

More topics at this stop

Stuck on this topic? Ask an Insider

Get 1:1 guidance from people who've walked this exact path — on the InsideEdge app.

Download
InsideEdge