cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Ricardo_Velaz
Regular Visitor

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, @Ricardo_Velaz 

 

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
MBAS on Demand

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

July 2021 Update 768x460.png

Check it out!

Click here to read more about the July 2021 Updates

Power Query PA Forum 768x460.png

Check it out!

Did you know that you can visit the Power Query Forum in Power BI and now Power Apps

Top Solution Authors
Top Kudoed Authors