KNOWLEDGE BASE

How to use other field for rank only for rows having same values


Published: 13 Oct 2021
Last Modified Date: 13 Oct 2021

Question

How to use other field for rank only for rows having same values.  Example: Rank by Value column when values are different (1,2,3)  but rank by Number when values in Value column are same (0)
 User-added image

Environment

  • Tableau Desktop

Answer

1. Duplicate Value column and convert to a discrete dimension - Name: Value (discrete)
2. Calculation (Count of values ):
{ FIXED [Value (discrete)]: COUNT([Value (discrete)])}
3. Rank for diff values:
if SUM([Count of values ])>1 then SUM([Value]) else RANK(SUM([Value]),'asc') end
User-added image
4. Show Number if values are same:
if SUM([Count of values ])>1 then SUM([Number]) end
User-added image
5. Rank for same values:
RANK([Number if values are same],'asc')

User-added image
6. Final Rank
if SUM([Count of values ])>1 then [Rank of same values] else [Rank for diff values] end
User-added image

 
Did this article resolve the issue?