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

Vote for your favorite vizzies from the Power BI Dataviz World Championship submissions. Vote now!

Reply
uj91
Helper I
Helper I

Sort legend for stacked chart as per the value (descending).

Below is a stacked bar chart

uj91_0-1765966298760.png

 

Top N is applied here and i want to sort the legends as per the bars. Any suggestions ? 

 

1 ACCEPTED SOLUTION

Hi @uj91,

Currently in Power BI, we can sort the bars in a stacked bar chart by value using Format → Layout → Sort by value. However, the legend order cannot be sorted based on the values shown in the chart.

The legend order always follows the order of the column used in the Legend field or the model sort order. It does not change dynamically based on Top N or measure values.

As a workaround, you can:

Control a fixed legend order using Sort By Column the data model, Use a separate table visual as a custom legend and sort it by value .Adjust Reverse order if stack direction helps visually legend order will still remain same.

So to confirm, sorting bars by value is supported, but sorting legends by value is not supported in Power BI at the moment.

A similar issue was discussed earlier. Please go through that thread, it may help resolve your issue.
Solved: Sort legend by value of legend items? - Microsoft Fabric Community

Hope this clarifies. Let us know if you want to explore any workaround further.
Regards,
Community Support Team.

View solution in original post

5 REPLIES 5
v-hjannapu
Community Support
Community Support

Hi @uj91,

I would also take a moment to thank @danextian  , for actively participating in the community forum and for the solutions you’ve been sharing in the community forum. Your contributions make a real difference.
 

I wanted to check if you had the opportunity to review the information provided. Please feel free to contact us if you have any further questions.

Regards,
Community Support Team.

Hi @uj91,
I hope the above details help you fix the issue. If you still have any questions or need more help, feel free to reach out. We are always here to support you.


Regards,
Community Support Team.

danextian
Super User
Super User

Hi @uj91 

In the formatting pane, there is an option under layout  to sort the bars by value

danextian_0-1765966746033.png

 





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

Did I answer your question? Mark my post as a solution!


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

I need the legends to be sorted as per the values as well. any suggestions ?

Hi @uj91,

Currently in Power BI, we can sort the bars in a stacked bar chart by value using Format → Layout → Sort by value. However, the legend order cannot be sorted based on the values shown in the chart.

The legend order always follows the order of the column used in the Legend field or the model sort order. It does not change dynamically based on Top N or measure values.

As a workaround, you can:

Control a fixed legend order using Sort By Column the data model, Use a separate table visual as a custom legend and sort it by value .Adjust Reverse order if stack direction helps visually legend order will still remain same.

So to confirm, sorting bars by value is supported, but sorting legends by value is not supported in Power BI at the moment.

A similar issue was discussed earlier. Please go through that thread, it may help resolve your issue.
Solved: Sort legend by value of legend items? - Microsoft Fabric Community

Hope this clarifies. Let us know if you want to explore any workaround further.
Regards,
Community Support Team.

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

Vote for your favorite vizzies from the Power BI World Championship submissions!

Sticker Challenge 2026 Carousel

Join our Community Sticker Challenge 2026

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

January Power BI Update Carousel

Power BI Monthly Update - January 2026

Check out the January 2026 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Users online (7,664)