4 Replies Latest reply on Jun 4, 2012 2:54 AM by Brian Near

    Sorting on 2 columns

    Brian Near

      Rank newbie here.  Have a simple view with "CSU" (store), "Noncons" (non-conformances), and "Selling Price" (value of non-conformances)

      I'm trying to sort by Noncons per CSU, which is no problem, but I also want to show Selling price in the sort,


      I can sort on either Noncons, *or* Selling Price, but can't get Noncons then Selling Price.  I'm probably going to be embarrased at how easy the answer is.  Here's my view:



      Thank you.

        • 1. Re: Sorting on 2 columns
          Alex Kerin

          Not so straightforward as you can't do a double sort.


          You can however create a calculated field to sort on where the part before the decimal is the first sort column and the part after is the second column. You just have to divide your second column by more than the max it could ever be


          Using the superstore example I was able to double sort by Order Quantity, then Profit by sorting on this calc field:


          sum([Order Quantity])+sum([Profit])/100000




          If your first column already has a decimal part, then you would need to divide by even more - however I guess this is a fringe case as it would be less likely that you would ever get a clash with decimals.

          1 of 1 people found this helpful
          • 2. Re: Sorting on 2 columns
            Brian Near

            Thank you!  I will have a look at this. 

            I'm glad I found out about the inability to double-sort.  I banged my head quite a bit with that.

            • 3. Re: Sorting on 2 columns
              Jonathan Drummey

              As with many issues in Tableau, there are multiple workarounds. I've attached another one. This uses a calculation on the first column that is set up to have the proper sort order, in the attached example I used -SUM([Number of Records]) as a stand-in for the # NonCons in your chart. Then I added that to the Rows shelf as a Discrete (blue pill) measure on the left side of the view, then unchecked Show Header. After that, we can sort descending on Sales and have it come out right.



              1 of 1 people found this helpful
              • 4. Re: Sorting on 2 columns
                Brian Near

                Thank you!  Something else I can learn from!