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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
taylororiger
Helper II
Helper II

Adjusting Sort Order

Adjusting Columns/Rows Sort Order
Tuesday
taylororiger_0-1646331622686.png

 

I have these "Years as EL" in those groups.  Is there a way to display those in the correct order? (5-9 should be after 0-4, for example).  I have this issue with a few tables where the sorting needs to be rearranged.  I know you need to create a reference/dimension table with the specificed sort order and use a "RELATED" function, but I can't figure out how to create a dimension/reference table either.  Please help!

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @taylororiger ,

 

[Year as EL] is a text type column, so Power BI will sort it by sort each word which is in same poisition. Power BI doesn't support us to sort a column by another calculated column which is built based on this one. So if you create a calcualted column like PijushRoy mention and sort [Year as EL] by this column, you will get an error as below.

1.png

Here I suggest you to create a conditional column in Power Query Editor and select change column type to whole number.

2.png

Then you can sort [Year as EL] by this custom column.

For reference: Sort one column by another column in Power BI Desktop

Result is as below.

1.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

2 REPLIES 2
Anonymous
Not applicable

Hi @taylororiger ,

 

[Year as EL] is a text type column, so Power BI will sort it by sort each word which is in same poisition. Power BI doesn't support us to sort a column by another calculated column which is built based on this one. So if you create a calcualted column like PijushRoy mention and sort [Year as EL] by this column, you will get an error as below.

1.png

Here I suggest you to create a conditional column in Power Query Editor and select change column type to whole number.

2.png

Then you can sort [Year as EL] by this custom column.

For reference: Sort one column by another column in Power BI Desktop

Result is as below.

1.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.

PijushRoy
Super User
Super User

Create a Calculated Column with below DAX
Sort Col= VAR _yearsasel = SELECTEDVALUE(Table'Years as EL')
SWITCH(
TRUE(),
_yearsasel = "0-4",1,
_yearsasel = "5-9",2,
_yearsasel = "10-14",2,
so on

Click the column YEARS AS EL and select SORT BY from ribbon and select new calculated column.
In the visual, 3 dot, Sort by YEARS AS EL and acceding order

If you have any question, please posted
If solve your requirement, please mark this answer as SOLUTION
If this comment helps you, please LIKE this comment/Kudos

Other option you can follow - https://community.powerbi.com/t5/Desktop/quot-Sort-by-column-quot-from-a-related-table/m-p/89265#M37...




Did I answer your question? Mark my post as a solution!
Appreciate your Like/Kudos

Proud to be a Super User!





Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.