2 Replies Latest reply on Sep 12, 2018 7:44 AM by Ciara Brennan

    Sharing tip: Sorting a table by columns

    Erick Amador

       

      Hi all,

       

      We came up with this simple solution to sort a table by individual columns (without modifying the column position within the table)

      Using parameters and a calculated field, we could achieve what i believe is one recurrent question on different Tableau forums

      There might be other ways to do the same, but this approach worked for our case

       

      For this we did:

      - Create a parameter list (numeric) with each column on the table we wanted to sort by (named "Sort By")

      - Create a parameter list (numeric) with the sort direction (named "Sort Order")

      - Create a custom field with the logic to sort the columns (named "Dynamic Sort")

      - Added two hidden columns at the beginning of the table to control the sort:

      1- INDEX()*[Sort Order]

      2- AGG([Dynamic Sort])

       

      Check the attached packaged file for the solution

       

      Hope this might be useful for someone out there

       

      (the sample dataset embedded is available here https://www.ibm.com/communities/analytics/watson-analytics-blog/sales-products-sample-data/ )

       

      best regards,

      Erick & Juan Carlos