Forum Discussion

TomSinAA's avatar
TomSinAA
Helper IV
2 years ago
Solved

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

 

  • 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
    )

3 Replies

  • Samarth_18's avatar
    Samarth_18
    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

    • TomSinAA's avatar
      TomSinAA
      Helper IV

      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: 

       

      • Samarth_18's avatar
        Samarth_18
        Community Champion

        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
        )