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