Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and a 50 percent discount on exams.
Get startedEarn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.
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?
Solved! Go to Solution.
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
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
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.
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
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
thanks, using measures, has solved my upside down traffic light
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
Hm I'm not getting the option to sort -- my only options are:
Sorry, I'm not at my PC so didn't check. I thought all charts had a sort feature there