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
bdpaasch
Advocate I
Advocate I

custom order for legend, sort using another column

Greetings all,

 

This is yet another round of, "I'm trying to custom sort a legend".... Lots of those questions here, sorry.

 

Modeling off of Parker Stevens' video (@https://www.youtube.com/watch?v=4xapOrfLvbg ) and Microsoft's page (@

https://docs.microsoft.com/en-us/power-bi/create-reports/desktop-sort-by-column?tabs=powerbi-desktop)  on the subject, I'm trying to sort a list of clients by another column to force sort an order of a legend.

 

However, the Client list is a couple dozen names long AND I want them to sort in order of our work load, therefore, a dynamic sort. A simple, manual 1, 2, 3, 4... doesn't do the job.

 

I created a separate Client table (names obscured for obvious reasons):

 

bdpaasch_0-1650996589891.png

 

 

The "Total Pick Records" is a calculated column via a measure:

 

bdpaasch_1-1650996637838.png

 

 

The measure is a simple count of records from my primary data table (making sure one particular data field isn't filtered):

 

bdpaasch_2-1650996671495.png

 

Some of the clients have no record values which will be the case from time-to-time. I then created a rank column using the Total Pick Records plus a little bit of alphabetical ordering to break ties.  ( @Fowmy  taught me that trick).

 

bdpaasch_3-1650996877882.png

 

Now I have a rank column that will update based on client workload (and then alphabetically in the case of work-load ties). I want to use that column to sort my legend (highest work-load clients to lowest). (I'll throw in a "greater than zero" filter on the visual to knock out the clients that didn't give us work in the time period.)

 

But, when I go to the "Sort by column" option on the ribbon under Column Tools and select "Rank Value" for the ordering, I get this error box:

 

bdpaasch_4-1650997115813.png

 

 

Anyone have any ideas?

 

Thanks!

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@bdpaasch , first of all, the sort column will not be dynamic, it will not use a measure. I think tying to create a column using a measure, that is giving an issue.

 

You can sort it on overall sales. Add a random number to make it different

View solution in original post

2 REPLIES 2
amitchandak
Super User
Super User

@bdpaasch , first of all, the sort column will not be dynamic, it will not use a measure. I think tying to create a column using a measure, that is giving an issue.

 

You can sort it on overall sales. Add a random number to make it different

@amitchandak Thanks. Based on what you wrote, I threw away my manually created Client Table. I created a referenced table from my data table, grouped the new table by client name and counted the rows (records) to create the workload numbers. I sorted the new little grouped table by client alphabetically, and added an index column. I created one more column, Force Rank, by adding the record count plus the index (divided by 1000) to break any ties that might form. Linked the Client fields from the two tables, did Sort By Column on the Force Rank and all good now. Thanks.

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.