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

The 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.

Reply
naskoiliev
New Member

Data label percentage of bar total

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 NumberSizeReturned?
145

Yes

245No
344Yes
445Yes
546No
646No
745No
845No
947Yes
1044No

 

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: 

 

naskoiliev_0-1690458131840.png

 

Ideally, we will have the percetage as a data label, but having it in tooltips would also be acceptable. 

 

Thanks for your help!

1 ACCEPTED SOLUTION
v-yiruan-msft
Community Support
Community Support

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 )

vyiruanmsft_0-1690789580188.png

Best Regards

Community Support Team _ Rena
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
v-yiruan-msft
Community Support
Community Support

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 )

vyiruanmsft_0-1690789580188.png

Best Regards

Community Support Team _ Rena
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

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!

Helpful resources

Announcements
Feb2025 Sticker Challenge

Join our Community Sticker Challenge 2025

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

Jan NL Carousel

Fabric Community Update - January 2025

Find out what's new and trending in the Fabric community.