(+351) 21 24 10006  ·  info@bconcepts.pt
Carnaxide, Lisbon

How to Calculate Percentage of Total in DAX: Step by Step

João Barros 10 de July de 2026 4 min read

Showing each value as a percentage of the total is one of the most requested analyses in any report: how much each category, region or product weighs within the grand total. In DAX, the trick is to compare the value in the current row against a total that ignores the filters of that same row. When that comparison is done right, the percentages always add up to 100% — and that is exactly what we will build here, from scratch and in a reusable way.

Prerequisites

  • Power BI Desktop installed, or the Power BI Service with a model you can edit.
  • A fact table with numeric values — we will use a Sales table with an Amount column.
  • At least one column to group the data by, such as Sales[Category].
  • How to create a simple measure with SUM. Nothing else is required.

Step 1: Create the base total measure

Before thinking about percentages, we need a measure that adds up the values. This measure reacts to the filter context: in a matrix by category it returns each category's total; on a total row it returns the total of everything.

Total Sales = SUM ( Sales[Amount] )

Create the measure with the New measure button and drag it into a matrix that has Sales[Category] on the rows. You should see a different value per category.

Step 2: Calculate the grand total with ALL

The percentage needs a denominator that does not change from row to row: the grand total. The ALL function removes the filters from a column or table, and CALCULATE re-evaluates the measure in that new, filter-free context. The result is the total of all categories, even when we are inside the row of a single one.

Grand Total =
CALCULATE (
    [Total Sales],
    ALL ( Sales[Category] )
)

If you add this measure to the matrix, you will notice it shows the same number on every row. It looks odd at first, but it is precisely the denominator we are after: the "whole" that each category will be compared against.

Step 3: Divide to get the percentage

Now we combine both ideas into a single measure. We use DIVIDE instead of the division slash because DIVIDE returns a blank (rather than an error) when the denominator is zero. The VAR variables make the formula easier to read and faster, because each value is calculated only once.

% of Total =
VAR CategoryTotal = [Total Sales]
VAR GrandTotal =
    CALCULATE ( [Total Sales], ALL ( Sales[Category] ) )
RETURN
    DIVIDE ( CategoryTotal, GrandTotal )

Finally, select the measure and format it as Percentage, with one or two decimal places. Each category now shows its real weight in the total.

Tip: give your measures clear names. "% of Total" is immediately understandable to anyone who opens the report months later.

Step 4: Respect filters with ALLSELECTED

There is a subtlety that makes all the difference. Because ALL removes every filter, it also ignores the slicers the user has chosen. If you filter by a year and want 100% to represent only that year, you need ALLSELECTED, which respects the filters coming from visuals and slicers.

% of Total (Selected) =
DIVIDE (
    [Total Sales],
    CALCULATE ( [Total Sales], ALLSELECTED ( Sales[Category] ) )
)

Rule of thumb: use ALL when 100% should always be the absolute total; use ALLSELECTED when 100% should reflect what the user has filtered in the report.

Verify the result

Put Sales[Category] in a matrix with the measures [Total Sales] and [% of Total] and look for two signs that everything is correct:

  • The percentage column adds up to 100% on the total row.
  • When you add a slicer by year, the ALLSELECTED version still adds up to 100%, while the ALL version now adds up to less than 100%, because it compares against the total of all years.

This "100% test" is the fastest way to confirm the result and to decide which function to use in each case.

Conclusion

With just three pieces — a base measure, a denominator using ALL or ALLSELECTED, and DIVIDE to avoid errors — you can calculate any percentage of the total in DAX and apply the same pattern to regions, products or customers. The next step is to calculate the percentage within a hierarchy, showing each product's weight inside its category. Which argument do you think you would need to change in the ALL function to achieve that effect?