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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
pranjaljain
Frequent Visitor

PowerBI Stacked Chart | Show % value as label in the legends | Display labels as % of row total

I am looking to Display measures as percentages in Power BI charts - Stacked bar chart. 

x-axis: Month year column

y-axis: Absolute Value

Legend: category

Display labels as percentage of row total. 

 

sample data 

MonthLondonParisTokyoTotal
Jan-23551525
Feb-2320253075
Mar-233530570
Apr-2310203060

 

Same data in percentage

 LondonParisTokyo
Jan-2320%20%60%
Feb-2327%33%40%
Mar-2350%43%7%
Apr-2317%33%50%


Desired output

pranjaljain_0-1686581313919.png

 

1 ACCEPTED SOLUTION

Hi , @pranjaljain 

Thanks for your response!

According to your description, you put Measure2. If you want to draw a bar chart of different data according to your Value, then you cannot place Measure2 but Measure.

vyueyunzhmsft_0-1687171057345.png

We just configured the display format of Measure on the basis of Measure:

vyueyunzhmsft_1-1687171154091.png

 

If configured purely like this, the Y axis will indeed display the full 20%, like this:

vyueyunzhmsft_2-1687171199141.png

If you want the Y axis to display the Y axis of your previous value, the only way is to create an identical visual, then configure the corresponding color, and hide the fields that do not need to be displayed; then finally we can achieve such a visual:

vyueyunzhmsft_3-1687171299989.png

 

The size of the bar chart will only be different according to the size of the value, we can only change the output format of the value, we cannot make a value have two different values.

 

 

Thank you for your time and sharing, and thank you for your support and understanding of PowerBI! 

 

Best Regards,

Aniya Zhang

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

7 REPLIES 7
pranjaljain
Frequent Visitor

This was really awesome. 

 

FYI - I just went one step ahead here by replacing the stacked column chart with a line and a stacked column chart. 

Now I reduced line stroke width to 0px(to make it invisible)

Then I enabled secondary y axis with 'sum of values' - Switched y axis positions, and made the y axis values colour as white. 

This allowed me to use only a single visual(rather than overlaping one on top of other)

 

This was really a major learning point and I really enjoyed it. Thanks for you support. 

v-yueyunzh-msft
Community Support
Community Support

Hi , @pranjaljain 

According to your description, you want to custom the measure format in your visual.

You can try to use the measure - dynamic feature.

First , we can create a  measure like this:

Measure 2 = var _total =  CALCULATE( SUM('Table'[Value]) , ALL('Table'[City]))
return
SUM('Table'[Value])/_total

 

Then we can configure it in the measure format:

vyueyunzhmsft_0-1686742287513.png

And then we can put this dax in it like this:

var _total = [Measure 2]
return
FORMAT(_total,"0%")

vyueyunzhmsft_1-1686742457286.png

Then we can get the result like this:

vyueyunzhmsft_2-1686742474943.png

For more information, you can refer to :
Create dynamic format strings for measures in Power BI Desktop - Power BI | Microsoft Learn

 

Thank you for your time and sharing, and thank you for your support and understanding of PowerBI! 

 

Best Regards,

Aniya Zhang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

pranjaljain
Frequent Visitor

https://file.io/U3i38mNE7Soz

 

Here is a link to Powerbi dataset pbix file

 @v-yueyunzh-msft 

Can you please check this pbix file for what I've done exactly. 

 

I did follow your method as well, But percentages are giving incorrect values

Hi , @pranjaljain 

Thanks for your quick response !

I tested it in your pbix file, you can try to convert the dax code of the format:

"""" & FORMAT([Measure 2],"0%")

 

Then we can  get this:

vyueyunzhmsft_0-1686792969110.png

Thank you for your time and sharing, and thank you for your support and understanding of PowerBI! 

 

Best Regards,

Aniya Zhang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

@v-yueyunzh-msft I did try the new workaround as well. Didn't work as expected

Visual: Stacked Column Chart

X-axis: Month-Year

Y-Axis: Measure 2

Legend: City

Output: 100% Stacked column chart

Am I missing anything?

Also I want Values column on y-axis

Hi , @pranjaljain 

Thanks for your response!

According to your description, you put Measure2. If you want to draw a bar chart of different data according to your Value, then you cannot place Measure2 but Measure.

vyueyunzhmsft_0-1687171057345.png

We just configured the display format of Measure on the basis of Measure:

vyueyunzhmsft_1-1687171154091.png

 

If configured purely like this, the Y axis will indeed display the full 20%, like this:

vyueyunzhmsft_2-1687171199141.png

If you want the Y axis to display the Y axis of your previous value, the only way is to create an identical visual, then configure the corresponding color, and hide the fields that do not need to be displayed; then finally we can achieve such a visual:

vyueyunzhmsft_3-1687171299989.png

 

The size of the bar chart will only be different according to the size of the value, we can only change the output format of the value, we cannot make a value have two different values.

 

 

Thank you for your time and sharing, and thank you for your support and understanding of PowerBI! 

 

Best Regards,

Aniya Zhang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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