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

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

Reply
wcarter
Advocate I
Advocate I

Sort legend by value of legend items?

I have a line chart with monthly granularity over a year. I need the legend at the top of the chart to sort by the count of items in each category and for the tooltip to sort by count of items in each category at the monthly level. I tried creating a rank column that has the desired granularity for monthly but it breaks the line chart, and if I try the yearly level the tooltip is out of order. If I try to sort the category column itself by the monthly column I get the error about not having multiple values in Y for sorting X. Is there any way to sort the legend by the values and not the categories?

 

Current tooltip/legend:

A2
B5
C1
D3

 

Desired tooltip/Legend

B5
D3
A2
C1
1 ACCEPTED SOLUTION
Oldnewbie
Frequent Visitor

PowerBI has enabled this functionality in the Visualisations pane now.

Here is how to do it.

1) Go to Columns:

Oldnewbie_0-1706857187871.png

2) Under Layout, turn 'Sort by value' to ON

Oldnewbie_1-1706857311086.png

3) You may choose to reverse order to keep largest quantity at bottom and smallest at top.

 

 

View solution in original post

10 REPLIES 10
Oldnewbie
Frequent Visitor

PowerBI has enabled this functionality in the Visualisations pane now.

Here is how to do it.

1) Go to Columns:

Oldnewbie_0-1706857187871.png

2) Under Layout, turn 'Sort by value' to ON

Oldnewbie_1-1706857311086.png

3) You may choose to reverse order to keep largest quantity at bottom and smallest at top.

 

 

thank you. I have searched a lot for this issue and this is the only solution that made sense

Looks like this works for sorting within the column, but does not reflect in the legend order. Anyone know how to sort the legend by value as well?

v-angzheng-msft
Community Support
Community Support

Hi, @wcarter 

You can use sort  column by another column feature; furthermore, you can also create a custom sort order by creating a new sort column. Then use the visual option "Sort Legend".
You can refer to the following blogs and videos to help you.
Sort Legend Power BI Feature Tutorial And Review

Sort Legend Tutorial And Review - Power BI November 2021 Updates

 

vangzhengmsft_2-1648517666616.png

 

 

 

Best Regards,
Community Support Team _ Zeon Zheng


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

This worked for me.

So the problem I have with this is that my Values on my line chart is a Count of the values in another column, and that second column has many duplicate values which gives me the error that 'There can't be more than one value in Column A for the same value in Column B" if I try to use it as the Sort By for Column A.

 

See below the issue I have with the Legend/Tooltip behavior, it only sorts by alphabetical of the legend items, I need to sort by value of the legend items:

sort-desired.jpg

 

Thank you!

please provide sample data as requested. Include a filter column so that we can create a measure based solution.

Here's a PBIX with sample data that fits the pattern I am working with. I need to sort Animal by Count of Sequence in the Tooltip so that when you hover over the line chart the items are in order of the values and not alphabetical, as indicated in my graphic. Thank you.

 

https://ufile.io/owksjf0j

@wcarter Thank you for providing the sample data. That helps a lot with proposing a potential solution.

See attached for a possible implementation with tooltip pages.

lbendlin
Super User
Super User

You can only sort a column by another column. If you want to sort a visual by a measure then you need to put that measure in the visual, or in the tooltips area.

 

Please provide sanitized sample data that fully covers your issue.

Please show the expected outcome based on the sample data you provided

 

 

Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

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

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

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