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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
Anonymous
Not applicable

Change the order of the legend and the bars.

Hello everyone,

I'm starting to build reports and I'm having some issues with changing the order of the legend in a bar graph. I have tried many of the options that I have found both in here and other sites, but haven't been able to do this for my case. The main issue here is that we also use the value of the legend as a slicer, so whenever I use one of the other options we lose the functionality of the slicer and can't seem to add another slicer that works for it.

 

Here is a general overview of the table:

 
MONTHCOST OPERATION ACOST OPERATION BCOST OPERATION C
ene-19   
feb-19   
mar-19   

 

I've tried using that table by adding each value in the order I want, but I can't seem to make another slicer and a filter for Top N.

The second table is a pivot of the first:

MONTHOPERATIONCOST
ene-19OPERATION A  
ene-19OPERATION B 
ene-19OPERATION C 
feb-19OPERATION A  
feb-19OPERATION B 
feb-19OPERATION C 
mar-19OPERATION A  
mar-19OPERATION B 
mar-19OPERATION C 

 

Here I use Operation for the legend, however power bi sorts them in alphabetical order. I want the legend be sorted by the Cost value. Is it possible to do so?

 

Either of the cases would work for me since I'm trying to organize the legend and the bars by value and not alphabetical order.

 

Thank you in advance!

2 REPLIES 2
v-alq-msft
Community Support
Community Support

Hi, @Anonymous 

 

Based on your description, I have created data to reproduce the scenario. It is unavailable to sort 'Operation' column in legend by the Cost value. The 'Operation' column should be based on another numeric column. You have to create an additional column "sort column" that just contains a simple integer value  to provide a defined order to column values, such as an index column, a conditional column.

 

For further information, you may refer to the following links.

https://community.powerbi.com/t5/Desktop/Sort-legend/m-p/262395

https://community.powerbi.com/t5/Desktop/Sort-Legends/m-p/569548

 

Best Regards

Allan

 

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

 

Tad17
Solution Sage
Solution Sage

You need to go into the table/data view, click in the column to be sorted, click "sort by column" and then select the surrogate sort column"

 

Stolen from here: https://community.powerbi.com/t5/Desktop/how-to-sort-a-column-by-other-column-which-is-not-used-in-t...

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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