Tableau has a variety of built-in solutions for Tableau ranking values in a data set. For most simple sorts, simply use the sort icons at the top. For more advanced cases, we use either the Tableau Index or Tableau Rank Calculated Fields. This is our first foray into the world of Tableau calculations.
Using the Tableau Rank Calculated Field
- In a new tab, right click on Profit and Create>Calculated Field.
- A window will pop up bringing Profit into the calculation window. Type Rank(Sum([Profit]),’desc’) in the window. This will create a calculation that will rank all your values in the view in Tableau. Title it Tableau Rank.
- Now drag Customer Name to Rows and Profit to the Text mark.
- Drag your Tableau Rank calculation to the Rows shelf, convert it to Discrete by right clicking on it, then drag it in front of Customer Name. You’ll see it’s now sorted the table by customer in terms of highest profit to least profit.
- That’s simple. But what if we wanted it to sort within varying levels of segments? For example, let’s say we want to see Profit from highest to lowest by Product Category per Customer Segment, and we want to restart the numbering for each segment.
- Add Segment and Category to the Rows shelf before Tableau Rank. Notice how the Tableau rank calculation is out of order.
- Click the down arrow on the Tableau Rank pill.
- Click Compute Using> Pane (Down).
- The Tableau Rank calc now starts over each product category segment.
- These show a few use cases of this calculation. It can become much more sophisticated. More information for more advanced use cases can be found online.
Practicing How to Use Tableau Rank Calculated Field
Scene 1
The new manager of Shipping and Logistics wants to know which Product Containers we ship by Ship Mode. He also wants to know the number of items we ship per container and ship mode.
- Bring Ship Mode to Columns and add Product Container to the Color shelf.
- Now, add Number of Records to Rows in the new sheet.
- Add labels.
- Bring another instance of Number of Records to the Label shelf. Make it show the Percent of Total. Compute using the Cell so that it calculates for each Ship Mode.
- Change the color palette to Blue-Red-Brown from the drop-down menu on the legend.
- Name the new tab “% Shipments by Mode & Container.”
Scene 2
The manager comes back and now wants to know which Ship Modes are used the most by Region. He also wants us to rank the Shipping Costs by Ship Mode and Region in a table in Tableau.
- Build a side-by-side bar chart, using Region and Ship Mode, and adding a second instance of Ship Mode to Color. Number of Records will be used as your measure.
- Name the tab “Ship Modes by Region.”
- Now open a new tab to build the table.
- Use Region and Ship Mode and Shipping Cost.
- Ensure Shipping Cost gets added to the Text/Labels shelf to make it a table.
- Create your Tableau Rank calculation on Shipping Cost, using rank_dense.
- Hint: ensure that you add the aggregation of Sum between Tableau Rank_dense and [Shipping Cost].
- Name your calc “Shipping Cost Rank.”
- Sort the table on Tableau Rank by putting it before the other dimensions in your view.
- You’ll notice that it doesn’t immediately give you this option. You’ll have to drag it to the end of the Rows shelf, where it will show as a green continuous pill. Click the down arrow, change it to Discrete, and then move the pill to the front.
- Which region and ship mode are the most expensive to ship to?
- Name the tab “Shipping Costs by Region and Ship Mode.”
- Build a simple dashboard with the worksheets you created to send to the Logistics manager. Name the dashboard “Logistics Dashboard.”
- Ensure each chart has a title and appropriate formatting. Feel free to Swap Rows and Columns to get things to fit the way you want. Set your legend to Floating.
- Add a title to the overall dashboard (accessed via the Dashboard menu at the top) and center it.
Did you like our detailed guide and practice test on using Tableau Rank? If you did, you are going to love our Tableau Training classes, made specifically for individual learners. We also offer corporate packages if you want to teach multiple team members at once.