MarkCBB
Active Member
- Joined
- Apr 12, 2010
- Messages
- 497
Hello,
I am busy messing around with some data to improve my DAX. I am using a very simple table (2 Columns, Column 1 = Product, Column 2 = Sales). (Note, unique list of products)
I am trying to get the percent of each Product i.e. sales contribution. When I create a pie chart with the 2 columns I get the expected result, the values are based on the value of the sum of sales.
Now I am trying to get the values in the Pie chart to show the percentage. I came up with the below Dax measure, and it works, but I am sure that there is a better way of doing this.
I am busy messing around with some data to improve my DAX. I am using a very simple table (2 Columns, Column 1 = Product, Column 2 = Sales). (Note, unique list of products)
I am trying to get the percent of each Product i.e. sales contribution. When I create a pie chart with the 2 columns I get the expected result, the values are based on the value of the sum of sales.
Now I am trying to get the values in the Pie chart to show the percentage. I came up with the below Dax measure, and it works, but I am sure that there is a better way of doing this.
Code:
% of = DIVIDE(CALCULATE(SUM(Sheet1[Sales]),FIRSTNONBLANK(Sheet1[Products],SUM(Sheet1[Sales]))),CALCULATE(SUM(Sheet1[Sales]),ALL(Sheet1[Products])),0)