HOW TO USE RANKS IN REAL TIME SCENARIOS IN TABLEAU
HOW TO USE RANKS
IN REAL TIME SCENARIOS
- In this example, let’s find the Top 3 selling Sub-Categories in each State. We would be using Sample superstore database and Tableau 10.3.
- Pull Sales onto columns and State and Sub-category onto rows.
- Create a Calculated field, call it ‘Rank’ and give ‘Index ()’. Index returns the row position.
- Pull the Rank onto Rows, in between State and Sub-Category. Change it from ‘Continuous’ to ‘Discrete’.
- You can find the Rank created, giving 1, 2,3 ... 656 across the whole table starting from Alabama to Wyoming.
- Let’s change the Rank such that it gives Rank Only State wise. It should start giving Ranks from 1, 2,3...n in each state.
- Right click on Rank, go to Compute Using, Choose the Option ‘Pane (Down)’ instead of ‘Table(Down)’. This action helps restart Rank (1 to n) in every State.
- Now, Let’s give the Ranks 1 to N to Sub-Categories such that the highest sales holds 1 and next highest 2 .. to do this, Right click on Rank, go to ‘Edit Table Calculation’. In ‘Compute Using’ select ‘Specific Dimensions’, Give the State and then Sub-Category stating that we want the computation to be done on State and then Sub-Category. ‘At the level’ give Sub-Category (this gives the Rank from 1 to n). ‘Restarting Every’ as ‘State’ (this restarts the Ranks from 1 when the new state starts). ‘Sort Order’ as ‘Custom Sort’ based on ‘Sales’ field with aggregation of ‘Sum’ and sort order being ‘Descending’.
- To get the top ‘N’ ranks, there are two ways of doing it.
- A simple way is to Pull the Rank onto Filters, Change the Rank in Filters, from Discrete to Continuous and then select ‘Show Quick Filter’. You can see a Slider ranging from 1 to 17. If you slide the utmost from 17 to 3, you can see only first 3 ranks in each State.
- We can also get a range Ranks starting from any number say 3 to 9 by sliding the atleast and utmost values.
- The second would be to create a Parameter. Name it Choose Rank, In the Range give the Min to 1 , Max to 17 (as there are 17 sub categories) and Step Size to 1.
- Now create a Calculated field to use this parameter as a filter. Name it ‘Choose Rank1’ and give the formula as ‘[Rank]<= [Choose Rank]’. (If you select the parameter as 3, it will give ranks from first to the third). This will give two values True and False. When you select True, it will give all values for which the condition is true.
- Note: The only Limitation here is we cannot select the atleast value, it has to start from Min value (1) to the utmost. Where as in the first method, you have the option to change the range of values both Atleast and Utmost.
Comments
Post a Comment