Bird
Raised Fist0
Tableaubi_tool~15 mins

Rank calculations in Tableau - Real Business Scenario

Choose your learning style10 modes available

Start learning this pattern below

Jump into concepts and practice - no test required

or
Recommended
Test this pattern10 questions across easy, medium, and hard to know if this pattern is strong
Scenario Mode
👤 Your Role: You are a sales analyst at a retail company.
📋 Request: Your manager wants to see which products are the top sellers each month and how they rank compared to others.
📊 Data: You have monthly sales data with columns: Month, Product, and Sales Amount.
🎯 Deliverable: Create a report that shows each product's sales per month and their rank within that month based on sales.
Progress0 / 6 steps
Sample Data
MonthProductSales Amount
JanuaryProduct A5000
JanuaryProduct B7000
JanuaryProduct C3000
FebruaryProduct A6000
FebruaryProduct B4000
FebruaryProduct C8000
MarchProduct A7000
MarchProduct B9000
MarchProduct C5000
1
Step 1: Connect your data source in Tableau and load the sales data.
No formula needed; just connect and import the data.
Expected Result
Data is loaded and visible in Tableau's Data pane.
2
Step 2: Create a worksheet to display sales by Month and Product.
Drag 'Month' to Columns, 'Product' to Rows, and 'Sales Amount' to Text on Marks card.
Expected Result
A table showing sales amounts for each product by month.
3
Step 3: Create a calculated field to rank products by sales within each month.
Create calculated field named 'Sales Rank' with formula: RANK_UNIQUE(SUM([Sales Amount]), 'desc')
Expected Result
A new field 'Sales Rank' that assigns a unique rank to each product's sales within the current partition.
4
Step 4: Set the partitioning for the rank calculation to be by Month.
Edit table calculation for 'Sales Rank': Compute Using 'Product', Restarting every 'Month'.
Expected Result
Ranking resets for each month, ranking products only within that month.
5
Step 5: Add the 'Sales Rank' calculated field to the worksheet next to sales amounts.
Drag 'Sales Rank' to Text or next to 'Sales Amount' in the view.
Expected Result
The table now shows sales amounts and the rank of each product per month.
6
Step 6: Format the worksheet for clarity: sort products by rank ascending within each month.
Sort 'Product' by 'Sales Rank' ascending within each month.
Expected Result
Products appear ordered by their sales rank for each month.
Final Result
Month    | Product   | Sales Amount | Sales Rank
----------------------------------------------
January  | Product B | 7000         | 1
January  | Product A | 5000         | 2
January  | Product C | 3000         | 3

February | Product C | 8000         | 1
February | Product A | 6000         | 2
February | Product B | 4000         | 3

March    | Product B | 9000         | 1
March    | Product A | 7000         | 2
March    | Product C | 5000         | 3
Product B was the top seller in January and March.
Product C led sales in February.
Ranking helps quickly identify the best and worst performing products each month.
Bonus Challenge

Create a dashboard that shows monthly sales trends and ranks for products with a filter to select a specific product.

Show Hint
Use a parameter or filter control for product selection and combine line charts for sales trends with rank tables.

Practice

(1/5)
1.

What does the RANK() function in Tableau do?

easy
A. It sums all values in a column.
B. It assigns a position number to each value based on order.
C. It filters data based on a condition.
D. It changes the data type of a field.

Solution

  1. Step 1: Understand the purpose of RANK()

    The RANK() function orders values and assigns a rank number to each based on their size.
  2. Step 2: Identify what RANK() does not do

    It does not sum, filter, or change data types; it only ranks values.
  3. Final Answer:

    It assigns a position number to each value based on order. -> Option B
  4. Quick Check:

    RANK() = position number [OK]
Hint: RANK() numbers items by size, like a race position [OK]
Common Mistakes:
  • Thinking RANK() sums values
  • Confusing RANK() with filtering
  • Assuming RANK() changes data types
2.

Which of the following is the correct syntax to rank sales in descending order in Tableau?

RANK(____, 'desc')
easy
A. COUNT(Sales)
B. AVG(Sales)
C. SUM(Sales)
D. MIN(Sales)

Solution

  1. Step 1: Identify the aggregation for ranking sales

    Ranking sales usually uses the total sales, so SUM(Sales) is appropriate.
  2. Step 2: Confirm syntax correctness

    RANK(SUM(Sales), 'desc') ranks sales from highest to lowest correctly.
  3. Final Answer:

    SUM(Sales) -> Option C
  4. Quick Check:

    Use SUM for total sales ranking [OK]
Hint: Rank totals with SUM() for correct order [OK]
Common Mistakes:
  • Using COUNT instead of SUM for sales
  • Using MIN or AVG which changes ranking meaning
  • Omitting aggregation inside RANK()
3.

Given the sales data below, what is the rank of Product B using RANK(SUM(Sales), 'desc')?

  • Product A: 500
  • Product B: 300
  • Product C: 700
  • Product D: 300
medium
A. 3
B. 2
C. 1
D. 4

Solution

  1. Step 1: Order products by sales descending

    Product C (700) is 1, Product A (500) is 2, Product B and D (300) tie next.
  2. Step 2: Assign ranks with ties

    Since B and D tie at 300, they share rank 3.
  3. Final Answer:

    3 -> Option A
  4. Quick Check:

    Product B rank = 3 [OK]
Hint: Ties share rank, next rank skips accordingly [OK]
Common Mistakes:
  • Assigning different ranks to tied values
  • Ignoring descending order
  • Ranking Product B as 2 instead of 3
4.

Identify the error in this Tableau rank calculation:
RANK(SUM(Sales), 'ascending')

medium
A. RANK() does not accept a second argument.
B. SUM(Sales) cannot be used inside RANK().
C. The function should be RANK_DESC() instead.
D. The direction should be 'asc' not 'ascending'.

Solution

  1. Step 1: Check valid direction keywords

    Tableau accepts 'asc' or 'desc' for direction, not 'ascending'.
  2. Step 2: Confirm other parts are correct

    SUM(Sales) is valid, RANK() accepts second argument, and RANK_DESC() is not a function.
  3. Final Answer:

    The direction should be 'asc' not 'ascending'. -> Option D
  4. Quick Check:

    Use 'asc' or 'desc' for direction [OK]
Hint: Use 'asc' or 'desc' exactly for rank direction [OK]
Common Mistakes:
  • Using full words like 'ascending' instead of 'asc'
  • Thinking RANK() can't take direction
  • Confusing RANK() with other functions
5.

You want to show the top 3 salespeople ranked by total sales, but if two salespeople tie for 3rd place, you want to show both. Which Tableau calculation should you use?

hard
A. Use RANK(SUM(Sales), 'desc') <= 3 to filter top 3 including ties.
B. Use INDEX() <= 3 to filter top 3 rows.
C. Use RANK(SUM(Sales), 'asc') <= 3 to filter top 3.
D. Use RANK_DENSE(SUM(Sales), 'desc') < 3 to filter top 3.

Solution

  1. Step 1: Understand ranking with ties

    RANK() assigns same rank to ties, so filtering with <= 3 includes all tied at 3rd.
  2. Step 2: Compare with other options

    INDEX() filters rows, not ranks; 'asc' ranks lowest sales; RANK_DENSE() does not skip ranks, so < 3 excludes ties at 3.
  3. Final Answer:

    Use RANK(SUM(Sales), 'desc') <= 3 to filter top 3 including ties. -> Option A
  4. Quick Check:

    RANK() <= 3 includes ties at 3rd [OK]
Hint: Filter with RANK() <= 3 to include ties at third place [OK]
Common Mistakes:
  • Using INDEX() which ignores ranking
  • Using ascending rank for top sales
  • Using RANK_DENSE() < 3 excludes ties at 3