Welcome to deBUG.to Community where you can ask questions and receive answers from Microsoft MVPs and other experts in our community.
1 like 0 dislike
87 views
in Power BI by 27 30 39

I have a sales dataset in Power BI with columns for ProductName and SalesAmount. I want to calculate the percentage contribution of each product to the total sales. For example, if the total sales are $10,000 and a product’s sales amount is $2,000, the percentage for that product should be 20%. How can I write a DAX measure to achieve this?


1 Answer

1 like 0 dislike
by 164 218 436

Calculate the Percentage of Total Sales Using DAX?

You can calculate the percentage of total sales by dividing the sales amount of each product by the total sales.

DAX Measure:

% of Total Sales = DIVIDE(SUM(Sales[SalesAmount]), CALCULATE(SUM(Sales[SalesAmount]), ALL(Sales)))

Explanation:

  • SUM(Sales[SalesAmount]): Calculates the total sales for the current context (e.g., a product or category).
  • CALCULATE(SUM(Sales[SalesAmount]), ALL(Sales)): Calculates the total sales across all products, ignoring any filters applied to the Sales table.
  • DIVIDE: Handles division, avoiding errors from dividing by zero.

Example in Action:

If you have the following data, the result should be as below:

ProductName	  SalesAmount   Percentage
Product A              $2,000        20%
Product B	             $3,000        30%
Product C	             $5,000        50%

This measure dynamically calculates the percentage of total sales for each product and displays it in your Power BI visuals.

If you don’t ask, the answer is always NO!
...