Power BI: How to Calculate Percent of Total by Category


You can use the following syntax in DAX to create a new column that displays the percent of a column total by category:

Percent of Team Total = 
'my_data'[Points]
    / CALCULATE (
        SUM ( 'my_data'[Points] ),
        ALLEXCEPT ( 'my_data', 'my_data'[Team] )
    )

This particular example creates a new column named Percent of Team Total that displays the percent of the total of the Points column, grouped by the values in the Team column.

The following example shows how to use this syntax in practice.

Example: Calculate Percent of Total by Category in Power BI

Suppose we have the following table in Power BI named my_data that contains information about points scored by basketball players on various teams:

Suppose we would like to add a new column that shows how much each individual value in the Points column represents as a percentage of the total values in the Points column, grouped by Team.

To do so, click the Table tools tab along the top ribbon, then click the New column icon:

Then type in the following formula into the formula bar:

Percent of Team Total = 
'my_data'[Points]
    / CALCULATE (
        SUM ( 'my_data'[Points] ),
        ALLEXCEPT ( 'my_data', 'my_data'[Team] )
    )

This will create a new column named Percent of Team Total that shows how much each individual value in the Points column represents as a percentage of the total values in the Points column for each team:

If you’d like to display the values as percentages, then click the dropdown arrow next to Format and then click Percentage:

Each of the values in the Percent of Team Total column will now be displayed as percentages:

Here is how to interpret the values in the Percent of Team Total column:

  • The first Mavs player accounts for 25.88% of all points scored by the Mavs.
  • The second Mavs player accounts for 16.47% of all points scored by the Mavs.
  • The third Mavs player accounts for 22.35% of all points scored by the Mavs.
  • The fourth Mavs player accounts for 35.29% of all points scored by the Mavs.

If we add up each of these percentages, we’ll find that the total is 100%:

Total Mavs Points: 25.88% + 16.47% + 22.35% + 35.29% = 100%.

The same is true for every other team in the table.

Additional Resources

The following tutorials explain how to perform other common tasks in Power BI:

How to Count Number of Occurrences in Power BI
How to Use “If Contains” in Power BI
How to Write an IF Statement in Power BI

Leave a Reply

Your email address will not be published. Required fields are marked *