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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
taylororiger
Helper II
Helper II

Adjusting Columns/Rows Sort Order

taylororiger_0-1646166578751.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.

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @taylororiger,

According to your description, it sounds like you want to achieve 'custom sort' effect. If that is the case, you can refer to the following link to create a custom sort table with sort order and set the 'sort by column' property.
Then you can link it to the raw table field and use new table fields on the matrix to replace the old one to apply for new sorting order.

Custom Sorting in Power BI 
Regards,

Xiaoxin Sheng

View solution in original post

10 REPLIES 10
PijushRoy
Super User
Super User

Hi @taylororiger 

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 let me know.
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!





sevenhills
Super User
Super User

To get the custom order in the desired way:

 

a) You need to have a dimension table and have a column to denote the sort order.

    Say "Years as EL - Sort Order" , and you can hide this column for report view

    Select the column "Years as EL" and then assign the "Sort by Column"
    "Years as EL"          "Years as EL - Sort Order"
    0-4                             1
    5-9                             2

   ... 

 

Rough idea, how it will look after the above steps:
 

sevenhills_0-1646167198750.png

 

 

b) refresh the chart, if it is not refreshed already

How do I create a dimension table?

In the home tab, create a table using 

sevenhills_0-1646331835282.png

 

 

My bad, Dimension table is a concept and you dont see it on any menu. Lookup or dimension table are data concepts. 

Thank you!  Would this work similarly for columns that need to be re-sorted?

Concept is same. You need additonal column to dictate the sort order for your requirements.

 

I like and do the lookup / dimension table concept.

 

For every custom display sort order type that we need, create a additional (separate) column to dictate the desired sort order.

 

Steps, more or less:

(A) if there is no separate table, add a new table without duplicates

    Say, in your case "Years as EL - Sort Order".

 

(B) A column to dictate the desired sort order. If no column, create new column.

      Say, in your case we added "Years as EL - Sort Order"

sevenhills_0-1646334836288.png

 

      Note: If there is another column that dictates the desired sort order, you can use that too.

           Let us take Calendar/Date table example,

           You have Month column: Jan, Feb, ...

           You have "Month Number" column: 1, 2, ... 

           Here you don't need new column, you can use Month Number column to dictate the sort order column for Jan, Feb.

 

(C) Set the sort order using power bi menu

(D) Hide the desired sort order column as it does not make sense for reporting visuals. 

 

Same thing you can achieve with DAX column also.

Build a dax colum like @PijushRoy  mentioned

The columns I am trying to re-order are the years, I want them shown the opposite way (starting with 2021 farthest left).  Would you be able to show how that would be done?

taylororiger_0-1646338093792.png

 

Anonymous
Not applicable

Hi @taylororiger,

According to your description, it sounds like you want to achieve 'custom sort' effect. If that is the case, you can refer to the following link to create a custom sort table with sort order and set the 'sort by column' property.
Then you can link it to the raw table field and use new table fields on the matrix to replace the old one to apply for new sorting order.

Custom Sorting in Power BI 
Regards,

Xiaoxin Sheng

I belueve your instructions are for re-sorting rows.  I was able to fix that issue, I am now trying re-sort the columns with my own custom sort order.  Is there a way to do this?  (I want the years displayed most recent to oldest from left to right).

Would you be able to visually show this?  I don't think I am following your instructions

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

September Power BI Update Carousel

Power BI Monthly Update - September 2025

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

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.

Top Solution Authors
Top Kudoed Authors