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
EmmaLynch
Frequent Visitor

Reordering legend in my Pie Chart

Hi,

 

I am very new to powerbi and trying to teach myself, but am unable to do the easiest of things it would seem.   😞   

Basically I just want to reorder my legend to show AA, A, B, C, and D.  

 

EmmaLynch_0-1598530338614.png

Any help received gratefully. (In layman terms please as Im not technical at all)

 

Thanks in advance .

 

1 ACCEPTED SOLUTION
Nimai123
Post Patron
Post Patron

Hi @EmmaLynch 

 

As Power BI doesn't know the order of the legend which is required in your case, to make it display the desired output we have to use the feature called Sort by Column.

 

Capture.PNG

So to use it you need to create a table where your Contract class hierarchy resides as follows

 

Capture1.PNG

Before sorting

Capture 2.PNG

After Sorting

Capture 4.PNG

 

To understand the model I have attached the sample file, you can download and apply in the main file

https://drive.google.com/drive/folders/1qpGEP3n954dyFkiIte8kGmjY8wGwt9yI?usp=sharing

View solution in original post

6 REPLIES 6
Nimai123
Post Patron
Post Patron

Hi @EmmaLynch 

 

As Power BI doesn't know the order of the legend which is required in your case, to make it display the desired output we have to use the feature called Sort by Column.

 

Capture.PNG

So to use it you need to create a table where your Contract class hierarchy resides as follows

 

Capture1.PNG

Before sorting

Capture 2.PNG

After Sorting

Capture 4.PNG

 

To understand the model I have attached the sample file, you can download and apply in the main file

https://drive.google.com/drive/folders/1qpGEP3n954dyFkiIte8kGmjY8wGwt9yI?usp=sharing

Greg_Deckler
Super User
Super User

@EmmaLynch - Use the ellipses (...) on the visual and choose Sort by and then Contract class

Greg_Deckler_0-1598530915865.png

 


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Mastering Power BI 2nd Edition

DAX is easy, CALCULATE makes DAX hard...

Hi,

Thanks for your speedy reply - greatly appreciated.

It was already set to sort by contract class.  The contract classes available are  AA, A, B, C & D but power BI is sorting them as A, AA, B, C, D.

I need to change this so that it knows AA comes first so the legend will show AA 1st insted of 2nd.

 

AA =Best

A= 2nd Best

B= 3rd Best

etc.....

 

Is this possible ?

Hi @EmmaLynch ,

 

Yes that's how Power Bi will sort them alphabetically.

What you can do is -  Give an order to your legend values: (create an ORDER ID column)

AA -->1

A -->2

B -->3

C -->4 and so on.

 

Then use SORT BY COLUMN functionality in Power BI to sort your Legend column using this Order id column.

 

Refer tihs article on how to custom sort your column:

https://radacad.com/sort-by-column-in-power-bi

 

Thanks,

Pragati

Best Regards,

Pragati Jain


MVP logo


LinkedIn | Twitter | Blog YouTube 

Did I answer your question? Mark my post as a solution! This will help others on the forum!

Appreciate your Kudos!!

Proud to be a Super User!!

Thanks so much for responding......

I added a "Contract Class Order Column" which has populated correctly using the below formula

 

Contract Class Order Column = if('Data v3 PMP20-Local-2020 06 19'[Contract class]="AA",1,if('Data v3 PMP20-Local-2020 06 19'[Contract class]="A",2,if('Data v3 PMP20-Local-2020 06 19'[Contract class]="B",3,if('Data v3 PMP20-Local-2020 06 19'[Contract class]="C",4,if('Data v3 PMP20-Local-2020 06 19'[Contract class]="D",5)))))

 

Then I went back and selected  "Contract Class" - clicked Sort by Column icon and selected my new "Contract Class Order Column" and entered.  Got error message saying "Sortby another Column - This column cant be sorted by a column that is already sorted, directly or indirectly by this column"

 

Any ideas ?

 

 

Hi @EmmaLynch ,

 

First thing try tagging the person you are responding to. It's easier to understand.

 

You are getting this error because your column is alreday sorted by some other column in your data.

 

Check the following link for a worksround:

https://community.powerbi.com/t5/Desktop/Sort-by-another-column-error/td-p/61341

 

Thanks,

Pragati

Best Regards,

Pragati Jain


MVP logo


LinkedIn | Twitter | Blog YouTube 

Did I answer your question? Mark my post as a solution! This will help others on the forum!

Appreciate your Kudos!!

Proud to be a Super User!!

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.