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

Sort by another column issue - already sorted?

Hi, 

 

I want to sort a list of 100 codes in the following way: 

Select 10 codes and sort them alphabetically first. And after these sort the rest of the codes alphabetically below. 

 

I created a new colum in order to give the 10 codes I wanted sorted on top number 1: 

Sorting number = SWITCH('Codes'[Code]; "JKA21"; 1;"JDF11"; 1;"JHD30"; 1;"JHW96"; 1;"JFG00"; 1;"JFB30"; 1;"JFB31"; 1;"JGB01"; 1;"JGB30"; 1;"JGB31"; 1; 2)
 
But when I try to sort my "code" column by another column "Sorting number" I get the following error message:

 

"This column can't be sorted by a column that is already sorted, directly or indirectly, by this column". 

 

What am I doing wrong? 

 

Thanks in advance!

1 ACCEPTED SOLUTION
QuinnP
Advocate II
Advocate II

Hi Lenerius

 

I just came across the same error!

 

For me the issue was that I was using DAX to definine a column (call it A) using another DAX defined column (call it B). Because A is sorted by itself by default, and A is defined by B, asking to sort B by A results in a circular reference. To fix this I redefined my DAX so that both A and B were sorted by an original table column, then everything worked fine!

 

Hope that helps!


Quinn

View solution in original post

3 REPLIES 3
QuinnP
Advocate II
Advocate II

Hi Lenerius

 

I just came across the same error!

 

For me the issue was that I was using DAX to definine a column (call it A) using another DAX defined column (call it B). Because A is sorted by itself by default, and A is defined by B, asking to sort B by A results in a circular reference. To fix this I redefined my DAX so that both A and B were sorted by an original table column, then everything worked fine!

 

Hope that helps!


Quinn

Anonymous
Not applicable

@QuinnPThanks! That ended up being my solution as well! Thanks for sharing!

v-shex-msft
Community Support
Community Support

Hi @Anonymous,

 

You can also refer to following blog to know how to create a related sort table to enable sort by column feature:

Custom Sorting in Power BI 

 

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

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.