Microsoft Fabric Community Conference 2025, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount.
Register nowThe Power BI DataViz World Championships are on! With four chances to enter, you could win a spot in the LIVE Grand Finale in Las Vegas. Show off your skills.
Hello,
I need help with creating a stacked bar / column chart with data labels showing percentages of the bar / column total and not the total for the entire chart. We also need to have the height / length of the bar / column reflect the absolute value. Our data is structured in a way similar to:
Serial Number | Size | Returned? |
1 | 45 | Yes |
2 | 45 | No |
3 | 44 | Yes |
4 | 45 | Yes |
5 | 46 | No |
6 | 46 | No |
7 | 45 | No |
8 | 45 | No |
9 | 47 | Yes |
10 | 44 | No |
The bar chart has "Size" in the Y-axis and count of "Serial Number" in the X-axis. The "Returned?" field is added as a legend. The desired outpoot should like:
Ideally, we will have the percetage as a data label, but having it in tooltips would also be acceptable.
Thanks for your help!
Solved! Go to Solution.
Hi @naskoiliev ,
I created a sample pbix file(see the attachment), please check if that is what you want.
Percentage =
VAR _part =
COUNT ( 'Table'[Serial Number] )
VAR _psize =
CALCULATE (
COUNT ( 'Table'[Serial Number] ),
FILTER (
ALLSELECTED ( 'Table' ),
'Table'[Size] = SELECTEDVALUE ( 'Table'[Size] )
)
)
RETURN
DIVIDE ( _part, _psize )
Best Regards
Hi @naskoiliev ,
I created a sample pbix file(see the attachment), please check if that is what you want.
Percentage =
VAR _part =
COUNT ( 'Table'[Serial Number] )
VAR _psize =
CALCULATE (
COUNT ( 'Table'[Serial Number] ),
FILTER (
ALLSELECTED ( 'Table' ),
'Table'[Size] = SELECTEDVALUE ( 'Table'[Size] )
)
)
RETURN
DIVIDE ( _part, _psize )
Best Regards
Thanks so much for the help and detailed info!
It's not quite I wanted as the bars now add to 100% and don't show the absolute value. However, I swapped the Y-axis and Tooltips measures, and now I have a workable result. I would have preferred to have the percentages as data labels rather than as tooltips, but this gets the job done as well.
Thanks again!
User | Count |
---|---|
143 | |
71 | |
69 | |
53 | |
52 |
User | Count |
---|---|
208 | |
94 | |
64 | |
60 | |
57 |