How to Use the Tableau Rank Calculated Field to Rank Profits

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

  1. In a new tab, right click on Profit and Create>Calculated Field. 
  1. 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. 
Tableau Rank
  1. Now drag Customer Name to Rows and Profit to the Text mark. 
  1. 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. 
How to Find Profit Rank in Tableau
  1. 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.   
  1. Add Segment and Category to the Rows shelf before Tableau Rank.  Notice how the Tableau rank calculation is out of order. 
  1. Click the down arrow on the Tableau Rank pill.  
  1. Click Compute Using> Pane (Down). 
  1. The Tableau Rank calc now starts over each product category segment. 
  1. 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.  
Shape

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. 

  1. Bring Ship Mode to Columns and add Product Container to the Color shelf. 
  1. Now, add Number of Records to Rows in the new sheet. 
  1. Add labels. 
  1. 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. 
  1. Change the color palette to Blue-Red-Brown from the drop-down menu on the legend. 
  1. 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. 

  1. 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. 
  1. Name the tab “Ship Modes by Region.” 
  1. Now open a new tab to build the table. 
  1. Use Region and Ship Mode and Shipping Cost. 
    • Ensure Shipping Cost gets added to the Text/Labels shelf to make it a table. 
  1. 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.” 
  1. 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. 
  1. Which region and ship mode are the most expensive to ship to? 
  1. Name the tab “Shipping Costs by Region and Ship Mode.” 
  1. Build a simple dashboard with the worksheets you created to send to the Logistics manager.  Name the dashboard “Logistics Dashboard.” 
  1. 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. 
  1. 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.