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

Learn from the best! Meet the four finalists headed to the FINALS of the Power BI Dataviz World Championships! Register now

Reply
TomSinAA
Helper IV
Helper IV

Sort Column Order in Matrix

I am trying to sort the column order of a matrix.  I created a helper column to use as the sort order.  But when I click the field for the columns in the matrix and click sort by the helper column I get an error message

TomSinAA_0-1721064605485.png

 

1 ACCEPTED SOLUTION

Hi @TomSinAA ,

 

you could try this code:-

StateSort = SWITCH(
    TMSShipmentDetail[State],
    "Awaiting", "1",
    "Tendered", "2",
    "Confirmed", "3",
    "Pick Ready", "4",
    "Intransit", "5",
    "Delivery Ready", "6",
    "Received", "7",
    "0"  // Default value in case none of the above conditions are met
)

Best Regards,
Samarth

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
Connect on Linkedin

View solution in original post

3 REPLIES 3
Samarth_18
Community Champion
Community Champion

Hi @TomSinAA ,

 

Could you please share the code that you have written for sorting?

And please provide some sample data with the expected output it help us to give you a more specific answer

Best Regards,
Samarth

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
Connect on Linkedin

Hi @Samarth_18 ,

I created a new column in my table using this formula:

StateSort = Switch(TMSShipmentDetail[State],"Awaiting", "1","Tendered", "2", "Confirmed", "3", "Pick Ready", "4", "Intransit", "5", "Delivery Ready", "6", "Received", "7").   Then clicked the State field in the right panel, then selected Sort column by and selected: StateSort.  It displayed this error: TomSinAA_0-1721227488725.png

 

Hi @TomSinAA ,

 

you could try this code:-

StateSort = SWITCH(
    TMSShipmentDetail[State],
    "Awaiting", "1",
    "Tendered", "2",
    "Confirmed", "3",
    "Pick Ready", "4",
    "Intransit", "5",
    "Delivery Ready", "6",
    "Received", "7",
    "0"  // Default value in case none of the above conditions are met
)

Best Regards,
Samarth

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
Connect on Linkedin

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.