When use what? - PART 6 - Rank_Unique can solve your problems!

Welcome back to “When use what?” blog post series…

Today I am going to write about how “Rank_Unique” function can solve your problems in Tableau sometimes!

Consider Superstore as your dataset. Imagine you want to find the TOP 10 products in the East Region by Profit Ratio by Year.

How would you do it in Tableau?

STEP 1

  • Drag Order Date and Product Name on Rows
  • Drag Profit and Sales on the table

step1_table

You will get the view below:

table_profit_sales

STEP 2

  • Create a calculated field to get your “Profit Ratio” as below:

calc_Profit_Ratio

  • Add it into the view. This is how our table looks like now:

FinalTable

  • Drag Region on the Filter Shelf and select only “East”

STEP 3

It is time to create our Rank function. My first attempt was the following calculated field:

rank1

Click on the calculated field and select the option “Convert to discrete”, then drag it on rows.

You will see that it won’t do it what you want (you can try, though) even if you edit the table calc…

rank_2

So, how to solve this issue? The answer is: RANK_UNIQUE!

Instead of the previous calculation, make this one:

rank_unique

It will basically force Tableau to make a unique rank for each row.

Make it discrete, then drag it into the view and do not forget to edit the table calculation (select advanced) in order to let it restart every year:

tablecalc1

tablecalc2

Then, drag your “rank unique” from the rows on the filter shelf (keep ctrl pressed) and select only the values between 1 and 1o in order to show your top 10.

Below your final table!

top10

Hope you enjoyed it.

A presto!

Author:
Simona Loffredo
Powered by The Information Lab
1st Floor, 25 Watling Street, London, EC4M 9BR
Subscribe
to our Newsletter
Get the lastest news about The Data School and application tips
Subscribe now
© 2024 The Information Lab