cancel
Showing results for 
Search instead for 
Did you mean: 

Fabric is Generally Available. Browse Fabric Presentations. Work towards your Fabric certification with the Cloud Skills Challenge.

Reply
wcarter
Frequent Visitor

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
6 REPLIES 6
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.

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
PBI November 2023 Update Carousel

Power BI Monthly Update - November 2023

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

Community News

Fabric Community News unified experience

Read the latest Fabric Community announcements, including updates on Power BI, Synapse, Data Factory and Data Activator.

Dashboard in a day with date

Exclusive opportunity for Women!

Join us for a free, hands-on Microsoft workshop led by women trainers for women where you will learn how to build a Dashboard in a Day!

Power BI Fabric Summit Carousel

The largest Power BI and Fabric virtual conference

130+ sessions, 130+ speakers, Product managers, MVPs, and experts. All about Power BI and Fabric. Attend online or watch the recordings.

Top Solution Authors
Top Kudoed Authors