We have already met measures such as Total Sales, and they seem to work without effort. The surprise comes when we divide one measure by another. On a table with thousands of orders, a "share of total" column can show 100% in every row. It looks like a bug in Power BI, but it is the formula doing exactly what we asked. To see why, we need one idea first, which is filter context.
What filter context means
A measure is not calculated once. Power BI calculates it again for every cell of a visual, and each cell has its own filters. The customer on the row is a filter. A slicer is a filter. A selected month is a filter. Together they are called the filter context. The measure SUM(Orders[total_amount]) only adds the orders that survive those filters.
Here is the sales table by customer. We can calculate every number by hand from the six orders.
| Customer | Total Sales |
|---|---|
| Ruby Hoang | 27,000,000 |
| Ethan Vu | 13,000,000 |
| Kevin Do | 20,000,000 |
| Sophie Ly | 18,000,000 |
| Total | 78,000,000 |
For the row Ruby Hoang, the filter context holds one filter, which is the customer Ruby Hoang. For the Total row, it holds no filter at all. That is why the same measure gives 27,000,000 in one place and 78,000,000 in another.
The trap: a share of total that is always 100%
To get each customer's share, we divide the customer's sales by the total sales. The first attempt below looks natural, because the denominator is the sum of the whole orders column.
// WRONG: the denominator is filtered by the same customer
Share Wrong = DIVIDE([Total Sales], SUM(Orders[total_amount]))In the row of Ruby Hoang, SUM(Orders[total_amount]) is also filtered to Ruby Hoang, so it returns 27,000,000. The measure computes 27,000,000 divided by 27,000,000, which is 100%. The same happens in every row. The formula never looks outside its own row.
CALCULATE changes the filter context
To change the filters of a measure, we use CALCULATE. Its first argument is the measure, and the next arguments are the new filters. ALL(Customers) removes every filter that comes from the Customers table. Because the customer filter reaches Orders through the relationship, removing it from Customers also removes it from the orders.
// RIGHT: the denominator ignores the customer filter
Share of Total =
DIVIDE(
[Total Sales],
CALCULATE([Total Sales], ALL(Customers))
)| Customer | Total Sales | Share Wrong | Share of Total |
|---|---|---|---|
| Ruby Hoang | 27,000,000 | 100% | 34.6% |
| Ethan Vu | 13,000,000 | 100% | 16.7% |
| Kevin Do | 20,000,000 | 100% | 25.6% |
| Sophie Ly | 18,000,000 | 100% | 23.1% |
| Total | 78,000,000 | 100% | 100.0% |
The check is simple. 27 divided by 78 is 34.6%, and the four shares add up to 100%. If your own numbers do not add up, the denominator is still being filtered.
CALCULATE with a column filter
The same function can add a filter instead of removing one. The measure below counts only the orders above 10 million.
Big Orders Sales = CALCULATE([Total Sales], Orders[total_amount] > 10000000)Four orders pass the filter, which are 15, 12, 20 and 18 million. So Ruby Hoang shows 27,000,000, Kevin Do shows 20,000,000, Sophie Ly shows 18,000,000 and the total is 65,000,000. Ethan Vu has two small orders of 8 and 5 million, so his value is blank. Blank is not zero, and a reader may need that said out loud.
When a slicer is involved
ALL(Customers) removes the customer filter completely, so the denominator stays at 78,000,000 even if a slicer picks two customers. That answers "share of the whole company". If we want "share of the customers selected", we use ALLSELECTED(Customers) instead. It removes the filter from the rows but keeps the selection made outside the visual, such as a slicer. Which one is right depends on the question, so state it in the title of the visual.
A check you can run every time
- Calculate one cell by hand from the source table.
- Add up the percentages. A share of total must reach 100% across all the rows together. A single row only holds a part of it.
- Put the grand total next to the rows and ask which filters each cell has.


