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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
i820017
Resolver II
Resolver II

Column Sorting

Hey Everybody,

 

I am trying to sort the following matrix differently.

i820017_0-1622736450061.png

I want the '>1 & <5' column and the '>=5' column to be switched.

 

 

I have created a 'SortOrder' column as seen below.

i820017_1-1622736649617.png

 

Then, in the data view, I highlighted the 'LabelKey' column and then clicked on 'Sort by Column'. When I sorted by 'SortOrder', I got this error.

i820017_2-1622736823100.png

 

I have a few questions.

First, what is the best way to switch the '>1 & <5' column and the '>=5'?

Second, why am I getting the error above? I have used the 'Sort by Column' before, and I have never gotten this error before.

 

 

Thanks

Dan 

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @i820017 

How did you get SortOrder column in Power Query? I build a sample and add and idex column in Power Query.
1.png

And I can sort the LabelKey or LabelDesc column by this Index column. We can see the '>1 & <5' column and the '>=5' column have been switched.

2.png

Best Regards,

Rico Zhou

 

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

 

 

View solution in original post

5 REPLIES 5
Anonymous
Not applicable

Hi @i820017 

How did you get SortOrder column in Power Query? I build a sample and add and idex column in Power Query.
1.png

And I can sort the LabelKey or LabelDesc column by this Index column. We can see the '>1 & <5' column and the '>=5' column have been switched.

2.png

Best Regards,

Rico Zhou

 

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

 

 

Adding that index column worked for me...thanks

i820017_0-1623165413147.png

 

i820017
Resolver II
Resolver II

I apologize for being unclear. The SortOrder column in DAX is not a calculated column. It is part of a table that I created in the Query Editor in Power BI as seen below.

i820017_0-1622738322882.png

 

 

Strange. I've never gotten this type of circular reference error with all columns defined in the query editor. Not sure what's going on then.

AlexisOlson
Super User
Super User

The error is likely because you defined SortOrder in DAX so that it's dependent on the label. Thus LabelKey depends on SortOrder depends on LabelKey, a circular reference.

 

The workaround is to add the sorting column in the query editor instead of as a calculated column in DAX.

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Solution Authors