3 Replies Latest reply on Sep 7, 2018 3:09 PM by Tableau Team

    Create group after sorting

    Tableau Team

      Say I have data like:

       

      fruitsNumber bought
      Apple5
      Banana10
      Peach3
      Banana4
      Apple1


      I want to create a sorted table that has the max number bought for each fruit with a new grouped column like:

      fruit MAX Number boughtfruit (group)
      Banana10A
      Apple5B
      Peach3C

       

      where A is assigned to the highest MAX Number bought value, B to the second highest.. and so on.

       

      Is there a way to achieve this? So far my data ends up looking like:

      fruitMAX Number Boughtfruit (group)
      Banana10B
      Apple5A
      Peach3C

       

      because the grouping happens independently of the sorting.

       

      FOLLOW UP QUESTION:
      The answers below helped with this specific case. The issue I'm running into now is that I need to use these 'A', 'B', and 'C' labels in a different table, but  RANK_UNIQUE([MAX Number bought]) is reapplied to all rows. Example:

       

      What I need:

      fruitNumber bought fruit (group)
      Banana10A
      Banana3A
      Apple1B
      Apple5B
      Peach1C
      Peach3C

       

       

      What I get:

      fruitNumber bought fruit (group)
      Banana10A
      Banana3C
      Apple1E
      Apple5B
      Peach1F
      Peach3D