Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
jgiles
Frequent Visitor

Percentage in clustered column chart visual

Hi,
I have a clustered column chart visual and the percentage is calculating across the grand total.   I'm trying to create a measure or column to calculate the level % by year.  Example Level A is 25%, B, 25%, C 40% and D 10% for YEAR 2020. I also provided a table below of what I'd want the percentage to be on the graph.  Also, a sample table of the data is below.  

2022-03-07_14-14-23.jpg  

 

 

Correct Percentage to display 
Level202020212022
A12.08%41.33%18.75%
B66.44%48.44%0.00%
C10.74%10.22%31.25%
D10.74%0.00%50.00%
 100.00%100.00%100.00%



Sample table:

YEARLevelCount
2021B109
2020B99
2021A93
2021C23
2020A18
2020C16
2020D16
2022D8
2022C5
2022A3


Thank you,

Julie

2 ACCEPTED SOLUTIONS
AllisonKennedy
Super User
Super User

@jgiles  I started working on this before @HotChilli  replied and then got interrupted. Am coming back to it now, so to expand on what @HotChilli  said, here's exactly how you can clear the filter on Level.

 

You've selected the % of GT - which clears filters on Level AND Year. You only want a subtotal, so only want to clear the filter on Level. Using the ALL function in DAX in combo with CALCULATE we can do this: 

 

% of all Levels Count =
DIVIDE(SUM(LevelsSample[Count]), CALCULATE(SUM(LevelsSample[Count]), ALL(LevelsSample[Level])))

 

AllisonKennedy_0-1646705955828.png'

 

Sample file attached below signature. Thanks @jgiles  for the easy to copy/paste sample data - you made it very easy to answer your question. 🙂 

 

 


Please @mention me in your reply if you want a response.

Copying DAX from this post? Click here for a hack to quickly replace it with your own table names

Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C

I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com

View solution in original post

@jgiles  That's an interesting one I haven't noticed, but it makes sense if my guess is right: My guess is that the column level is sorting by is actually applying the filter too, so you need to add 

ALL(Table[LevelSortColumn]) 

as a filter argument too and that should do the trick. 


Please @mention me in your reply if you want a response.

Copying DAX from this post? Click here for a hack to quickly replace it with your own table names

Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C

I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com

View solution in original post

8 REPLIES 8
AllisonKennedy
Super User
Super User

@jgiles  I started working on this before @HotChilli  replied and then got interrupted. Am coming back to it now, so to expand on what @HotChilli  said, here's exactly how you can clear the filter on Level.

 

You've selected the % of GT - which clears filters on Level AND Year. You only want a subtotal, so only want to clear the filter on Level. Using the ALL function in DAX in combo with CALCULATE we can do this: 

 

% of all Levels Count =
DIVIDE(SUM(LevelsSample[Count]), CALCULATE(SUM(LevelsSample[Count]), ALL(LevelsSample[Level])))

 

AllisonKennedy_0-1646705955828.png'

 

Sample file attached below signature. Thanks @jgiles  for the easy to copy/paste sample data - you made it very easy to answer your question. 🙂 

 

 


Please @mention me in your reply if you want a response.

Copying DAX from this post? Click here for a hack to quickly replace it with your own table names

Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C

I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com

Thank you very much, I wish I had seen this before, I used to break my data in separated tables to get the same result.

@AllisonKennedy One more question.  Why wouldn't this work if the Level was sorted by a different column?  I'm getting 100% but if I change the sort order of Level back to just Level it works.  Thank you!

@jgiles  That's an interesting one I haven't noticed, but it makes sense if my guess is right: My guess is that the column level is sorting by is actually applying the filter too, so you need to add 

ALL(Table[LevelSortColumn]) 

as a filter argument too and that should do the trick. 


Please @mention me in your reply if you want a response.

Copying DAX from this post? Click here for a hack to quickly replace it with your own table names

Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C

I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com

@AllisonKennedy Thank you so much for you help!  That worked.  Appreciate it 🙂

Thank you @AllisonKennedy Appreciate the help!

HotChilli
Super User
Super User

The value on the chart is a measure that represents SUM(SampleTable[Count]),

so you need to write a measure that takes this value and divides it by the same measure which has the Level filters removed.

Is that enough to get you started?

Thank you @HotChilli 

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel1

Power BI Monthly Update - May 2024

Check out the May 2024 Power BI update to learn about new features.