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
swong
Helper II
Helper II

stacked graph order

Hi,

 

I have a stacked bar chart, and the different segments are:

 

Exact, Full, Partial, Traditional

 

My bars are stacked in that order (alphabetical), with "Exact" on the bottom and "Traditional" on top. However, I want my segments to be ordered the opposite, with "Traditional" on bottom and "Exact" on top.

 

I created a Sort table, with each of my segments and it's corresponding order, e.g. (Traditional, 1), (Partial, 2). I then added a column to my original table:

 

Sort Order = RELATED(SortTable[Sort Order])

 

and sorted the original table by this column. However, this didn't change the order of segments in my stacked bar chart. How can I make the chart reflect my custom ordering?

1 ACCEPTED SOLUTION
v-yulgu-msft
Employee
Employee

Hi @swong,

 

Currently, it is not supported to sort the chart based on legend. Someone has submitted this feature request, you can clisk to vote it up. Custom order for legend in stacked bar chart

 

As a workaround, you could create Measures for each segment. Then place each Measure in the Values area in the order you need. However, this workaround might not apply to the scenario where you have many legend items.

 

Regards,
Yuliana Gu

Community Support Team _ Yuliana Gu
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

11 REPLIES 11
Betacom
Frequent Visitor

The workaround that worked for us:

The legend is sorted by symbols then numbers then alphabetically.  I was able to adjust the caculated measure column result (legend) descriptions to adjust the ordering.

 

So, in my case:

< 6  Days

06-14 Days

14+ Days

Average Days

Chels
Frequent Visitor

You can also solve this simply by creating separate measures for each variable you would like to show on the stacked chart. You can then order them as you wish in the column values field under Visualisations.

I think I have a solution to this.

 

If you set up a separate Table (use Enter Data) containing Exact, Full, Partial, Traditional  and then type 1,2,3,4 in the column next to it you can then connect that to your table that is currently being used in your chart.

 

Use this new column of of segment names in your chart instead of the original ones.

 

You can then use the Sort By Column option under Modelling to get your segments to show any order you want.

v-yulgu-msft
Employee
Employee

Hi @swong,

 

Currently, it is not supported to sort the chart based on legend. Someone has submitted this feature request, you can clisk to vote it up. Custom order for legend in stacked bar chart

 

As a workaround, you could create Measures for each segment. Then place each Measure in the Values area in the order you need. However, this workaround might not apply to the scenario where you have many legend items.

 

Regards,
Yuliana Gu

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

The proposed workaround of using measures for sorting is not acceptable for my organization's purposes.  By using measures in place of a single Legend column, we lose the ability to filter or drill from the individual bar segments.

 

UPDATE: I found a solution that worked for me.  In involves setting the "Sort By Column" property on the column itself, either in the embedded Power BI model or in SSAS.  For more info, see here: https://stackoverflow.com/questions/51156029/how-to-sort-a-bar-chart-in-microsoft-power-bi-desktop

 

 

Anonymous
Not applicable

thanks, using measures,  has solved my upside down traffic lightorder of traffic light.PNG

Anonymous
Not applicable

Hi, can you share the measure plz.

Can you share your measure?

Have you tried sorting from the ellipsis in the top right corner of the chart. Not sure if that affects the stack order or not



* Matt is an 8 times Microsoft MVP (Power BI) and author of the Power BI Book Supercharge Power BI.

Hm I'm not getting the option to sort -- my only options are:

 

EllipsesPic.PNG

Sorry, I'm not at my PC so didn't check. I thought all charts had a sort feature there 



* Matt is an 8 times Microsoft MVP (Power BI) and author of the Power BI Book Supercharge Power BI.

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.

Top Solution Authors