How to create Top 5 and Bottom 5 values with respect to a Measure in Bar graph in same worksheet
Just figured out a simple way of dealing with this class of questions.
Top 5 and Bottom 5
For top 5 and bottom 5, this line of code as filter will suffice: (Use Rank() if you wish)
- Rank_Unique(Sum([Sales]))<=5 or Rank_Unique(-Sum([Sales])<=5
- Rank_Unique(Sum([Sales]))<=5 or Rank_Unique(Sum([Sales],'asc')<=5
Sort the result to make it look better. But sorting may not be a requirement.
Top N and Bottom N
To generalize a bit, for top N and bottom N, we can do this using a parameter N:
- Rank_Unique(Sum([Sales])<=N or Rank_Unique(-Sum([Sales])<=N
Color is nice to differentiate. Use this calculated field to color:
- Rank_Unique(Sum([Sales]))<=5
Create a calc field Rank_Unique:
- Rank_Unique(Sum([Sales]))
Voila! Click below to download the workbook.
AhÃ! Claro y sencillo. Excelente!!
ReplyDeleteTo get Min/Max in one shot:
ReplyDeleteRank_Unique(Sum([Sales]))=1 or Rank_Unique(-Sum([Sales])=1
Marvelous!!!!!!!!!! Thank You Thank You Thank You....I had been using a very complicated script to accomplish what you achieved so brilliantly and elequently...Thank You! I've seen may examples of ideas to accomplish this task. But this is the best!
ReplyDeleteEnjoy Tableau!
Delete