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
Anonymous
Not applicable

How to order legend values which appears on Mouse Hover in Line chart?

I have a line chart, it is ordred properly but when I hover my mouse over to each data point, those values are not in the order I want. how do I change that? Example screenshot is shown below:

Power BI Desktop- Line chart.png

In Above screenshot I hovered over to June and I got All legents but I want to order this legend by Value not Legend lable. How do I do that?

1 ACCEPTED SOLUTION

Hi @Anonymous,

In both examples, the fields are unchanged and look like this:

image.png

Note that the Tooltips field is empty.

The difference between examples is that in the second one, I created a column called Country Sort that I used to sort the Country column by, as shown in the article I linked in my above post (specifically this section), e.g.:

image.png

This is because the visual itself does not allow (or think it needs to allow) sorting, so you can force the Legend value to sort by using the sort by column approach.

You will need to determine how this sort value is generated, based on your data. Note that values for each value of the field that goes into Legend will need to be unique for your sort column. Here's a partial table of how these fields look side-by-side so you can see how you might want this to work in your report:

image.png

This is also a design pattern you would want to use to create ordinal attributes that shouldn't sort alphabetically, e.g. month name.

Good luck!

Daniel


If my post helps, then please consider accepting as a solution to help other forum members find the answer more quickly 🙂





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

Proud to be a Super User!


My course: Introduction to Developing Power BI Visuals


On how to ask a technical question, if you really want an answer (courtesy of SQLBI)




View solution in original post

6 REPLIES 6
dm-p
Super User
Super User

Hi @Anonymous,

The order is dictated by the field you're using in the Legend box - you'll notice that the values are sorted alphabetically.

If you want to change this, you'll need to assign a sort by column to the field you're using.

Here's an example with some data I have - countries are sorted alphabetically:

Initial chart - sorted by field valueInitial chart - sorted by field value

Now, I've applied a custom order to my countries - note that they appear differently:

Same chart, after modifying how the field is sorted (by another column)Same chart, after modifying how the field is sorted (by another column)

You should be able to see the differences between both examples, including the legend sort order.

Hopefully this should be all you need to get moving. Good luck!

Daniel


If my post helps, then please consider accepting as a solution to help other forum members find the answer more quickly 🙂





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

Proud to be a Super User!


My course: Introduction to Developing Power BI Visuals


On how to ask a technical question, if you really want an answer (courtesy of SQLBI)




Anonymous
Not applicable

I see. Thank You very much for your time. is it possible for your to show a screenshot of your Visualization fields on the right? I was thinking it is something to do with tooltips. 

Hi @Anonymous,

In both examples, the fields are unchanged and look like this:

image.png

Note that the Tooltips field is empty.

The difference between examples is that in the second one, I created a column called Country Sort that I used to sort the Country column by, as shown in the article I linked in my above post (specifically this section), e.g.:

image.png

This is because the visual itself does not allow (or think it needs to allow) sorting, so you can force the Legend value to sort by using the sort by column approach.

You will need to determine how this sort value is generated, based on your data. Note that values for each value of the field that goes into Legend will need to be unique for your sort column. Here's a partial table of how these fields look side-by-side so you can see how you might want this to work in your report:

image.png

This is also a design pattern you would want to use to create ordinal attributes that shouldn't sort alphabetically, e.g. month name.

Good luck!

Daniel


If my post helps, then please consider accepting as a solution to help other forum members find the answer more quickly 🙂





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

Proud to be a Super User!


My course: Introduction to Developing Power BI Visuals


On how to ask a technical question, if you really want an answer (courtesy of SQLBI)




Anonymous
Not applicable

This may work in a normalized table but my table have data that gets aggregated in the line graph. Sorting column seems tobe difficult. For example my data looks like this:

 

DocsDateXCountYCount
A11/20/201901
B11/20/201951
C11/20/201910
A12/21/201901
B12/22/201932
D12/22/201910
A12/23/201942

 

I have Mutiple document codes for every day and counts for each day. Now my chart shows these counts by Month- means it aggregates counts to month level by each document code. How do I sort document by Ycount now-  that is the agregated count in chart but no aggregated in table?

 

Thanks

Hi @Anonymous,

If you can't reproduce the measure result as a calculated column then the sort by column approach will not work for you, as you have discovered. This is now a little beyond my knowledge, and it might be better to ask the DAX forum if they have any suggestions for you - that forum has a lot more traffic and people who may be able to suggest an alternative much faster than the Developer forum.

Regards,

Daniel





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

Proud to be a Super User!


My course: Introduction to Developing Power BI Visuals


On how to ask a technical question, if you really want an answer (courtesy of SQLBI)




Anonymous
Not applicable

I see okay. Thank you for your help. I think your solution is definitely going to work for other situations. 

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.