5 Replies Latest reply on Sep 13, 2017 10:53 AM by Jennifer VonHagel

    How can we sort Column based on several metric / columns in Tableau

    vikram arora

      Hi All,

       

      Thanks for always supporting. Please help me understand that how we can sort a column ( Customers)   based on several metric / column in tableau at the same time.

       

      Means can we perform multiple sorting in tableau using columns ( Brand Rx Vol, Brand Rx Share of TA , TA Rx Vol  and TA Rx share of Total ) ?

       

      Refer to the screenshot below

            

      Customers CitZIPBrand Rx volBrand Rx share of TATA Rx volTA Rx share of total
      Customer A1111
      Customer B1111
      Customer C2222
      ...
      Customer Z10101010

       

      Please let me know if more clarification is needed on the question.

       

      Thanks & Regards

      Vikram Arora

        • 1. Re: How can we sort Column based on several metric / columns in Tableau
          Jennifer VonHagel

          Hi Vikram, what is the order you wish to sort by (sort measureA first, then measureB second, etc.) and is the order you want to sort by static, or might it change?

           

          Also will you have more than 1 dimension on rows shelf?

           

          Thanks,

          Jennifer

          • 2. Re: How can we sort Column based on several metric / columns in Tableau
            vikram arora

            Thanks Jennifer for the reply.

             

            We need to sort the data using either of the columns ( Brand Rx Vol , Brand Rx Share of TA , TA Rx Vol and TA Rx Share of Total )

             

            Columns should be used to sort the data.

             

            Regards

            Vikram

             

            • 3. Re: How can we sort Column based on several metric / columns in Tableau
              Peter Fakan

              Hi Vikram,

               

              It sounds like you are trying to perform an excel function in Tableau. Nearly every pill that you drop into Tableau can be sorted by clicking the sort button.

               

              If you right click on the data and select Sort you get the usual style sort functions.

               

               

              However... This will just give you the equivalent of an excel sheet in Tableau. I'd suggest as an alternative to drop the fields onto your filters shelf (make sure you select everything), and then expose the filters out on a dashboard. This will turn your dashboards into a much more interactive product.

               

              HTH

               

              Peter

              • 4. Re: How can we sort Column based on several metric / columns in Tableau
                vikram arora

                Well Thanks Peter for your help.

                 

                Let me try it on Dashboard. I will get back to you in case if i have any doubts.

                 

                Thanks once again.

                 

                Best Regards

                Vikram Arora

                • 5. Re: How can we sort Column based on several metric / columns in Tableau
                  Jennifer VonHagel

                  Hi Vikram,

                   

                  If you have a single Dimension (Customer Name) and all other columns are set up as measures, you can sort easily. Sales is currently sorted ascending, but if I hover over Profit or Profit Ratio or Quantity, I get the sort icon which I can click to sort by that column.

                   

                  When you have two or more dimensions on the view, the sorting becomes kind of confusing.

                   

                  Here is a view, I haven't tried to sort by anything yet. It defaulted to sort alphabetically by Region, then by Customer Name.

                  If I click the sort icon over profit, I get this. Notice that the descending sort icon now shows up on Profit AND on Customer Name, indicating these are sorted. But look at the numbers in Profit. I would have expected that for each Region, profit would be in descending order. Sometimes it is (East), and sometimes it isn't (all the others). So that is clearly not what is happening.

                   

                  Look at the Customer Names though: they are sorted in the same order for each region. So what's happening is that Customer Name is the column that is getting sorted, and Profit is a condition of how that column gets sorted. So let's look at it.

                  If I right-click on Customer NAME, and choose Sort, I can see that Customer Name is being sorted by Sum of Profit.

                  So Tableau is first finding each Customer's sum(Profit), then sorting customer name descending by that, and applying this customer name sort order to each region.  See here without region the order of names - this is the same order of names happening in each region a couple screenshots prior.

                  Ok, so one option to let you sort your table truly by the measures is to concatenate all the dimension in your view:

                   

                  I will click Region, CTRL+Click Customer Name, so both are selected. Right-click, choose Create > Combined Field.

                  I put the combined field on the view, and now I can sort by any of the measures, and it will sort ascending and descending across the whole table.

                   

                  This has its own limitation, though. I now cannot sort the dimensions - I can't sort Region or Customer Name. Also, I can't sort within Region, so say I want to sort the table by profit descending within each Region - can't do it.

                   

                  You can hide the combined field. Click the arrow on the pill, and un-check Show Header.

                  I hope this helps!

                   

                  Best,

                  Jennifer