How to Get Top 5 in Tableau

Cody Schneider7 min read

One of the most common requests in data analysis is to isolate your top performers - whether it's your top 5 products, top 10 salespeople, or top 3 marketing channels. Cutting through the noise to see what's working best is essential. This article will show you several ways to calculate and display the Top 5 in Tableau, starting with the simplest filter and moving to more flexible and dynamic methods.

GraphedGraphed

Your AI Data Analyst to Create Live Dashboards

Connect your data sources and let AI build beautiful, real-time dashboards for you in seconds.

Watch Graphed demo video

Why Isolate Your "Top N" Performers?

Analyzing your "Top N" - where N can be 5, 10, or any number you choose - is a fundamental practice in business intelligence for a few key reasons. It immediately helps you simplify complex datasets, making them easier to understand at a glance. Instead of looking at a list of 1,000 products, focusing on the Top 5 lets you spot trends and patterns among your most important items.

This focus allows for better decision-making and resource allocation. For example, by identifying your:

  • Top 5 selling products: You know which items to keep in stock, feature in marketing, or analyze to understand their success.
  • Top 5 sales representatives: You can recognize high achievement, learn from their strategies, and create mentorship opportunities.
  • Top 5 marketing campaigns by ROI: You know where to double down on your advertising budget for the best returns.

Filtering for the 'best of the best' helps you move from raw data to actionable insights quickly. Now, let's look at how to actually do it in Tableau.

Free PDF Guide

AI for Data Analysis Crash Course

Learn how to get AI to do data analysis for you — the best tools, prompts, and workflows to go from raw data to insights without writing a single line of code.

Method 1: The Quick and Easy Filter Method

This is the most direct way to get a Top 5 list. It's perfect for quick, one-off analyses where you don't need the list to be interactive or used elsewhere in your workbook.

Let's imagine you have a bar chart showing Sales by Sub-Category, and you want to narrow it down to the top 5 highest-grossing sub-categories.

Step-by-Step Instructions:

  1. Build your initial view: Drag the dimension you want to rank (e.g., Sub-Category) to the Rows shelf and the measure you want to rank by (e.g., Sales) to the Columns shelf.
  2. Add the filter: Drag the Sub-Category dimension from the Data pane directly onto the Filters shelf. A dialog box will pop up.
  3. Configure the Top filter: In the dialog box, navigate to the Top tab.
  4. Apply the filter: Click OK. Your view will immediately update to show only the top 5 sub-categories based on their total sales. We also recommend sorting your view descending to see the rankings clearly.

Pros: This method is incredibly fast and intuitive. It takes just a few clicks to implement and is easy for beginners to understand.

Cons: The filter is static. If you want to change it to a Top 7 or a Bottom 5, you have to manually go back in and edit the filter. It's less flexible for dashboards where you might want the user to control the ranking.

Method 2: Using a Set for More Flexibility

Sets are a fantastic feature in Tableau that let you group members of a dimension. Creating a set for your Top 5 gives you a reusable element you can apply to multiple worksheets or use within calculated fields.

Using the same Sales by Sub-Category example:

Step-by-Step Instructions:

  1. Build your initial view: Just like before, create a bar chart with Sub-Category on Rows and Sales on Columns.
  2. Create the Set: In the Data pane on the left, find your dimension (Sub-Category). Right-click on it and select Create > Set.
  3. Configure the Set: A dialog box will appear.
  4. Use the Set as a filter: Click OK. You'll now see your new set in the Data pane. Drag this set onto the Filters shelf. Your view will now be filtered to the Top 5 members you defined. The members in the set (the Top 5) are shown as "In", and all others as "Out".

Pros: Sets are reusable. You can drag the same "Top 5 Sub-Categories" set to other charts. You can also use them in calculations to compare the "In" group to the "Out" group (e.g., to create an "All Others" category).

Cons: Just like the simple filter, the number ("5") is hardcoded. It is still not interactive for the end-user out of the box.

GraphedGraphed

Your AI Data Analyst to Create Live Dashboards

Connect your data sources and let AI build beautiful, real-time dashboards for you in seconds.

Watch Graphed demo video

Method 3: Advanced Control with the INDEX() Function

For the ultimate control over ranking and sorting, table calculations are the way to go. The INDEX() function assigns a number (1, 2, 3...) to each row in your partition, which effectively acts as a rank. This method is particularly useful when ranking is dependent on other table calculations.

Step-by-Step Instructions:

  1. Build your view and sort it: Create your chart with Sub-Category on Rows and Sales on Columns. Crucially, you must click the sort icon to sort the chart descending by SUM(Sales). The ranking depends on the sort order.
  2. Create the INDEX() Calculation:
  3. The formula is simply:
  4. Add the Rank to your view (for checking): Drag your new Rank calculation to the Rows shelf, right before your Sub-Category pill. Right-click the Rank pill and change it to Discrete. You will now see numbers 1, 2, 3, etc., next to each sub-category, confirming your ranking is working as expected.
  5. Filter by Rank: Now, drag the Rank calculated field (this time from the Data pane) onto the Filters shelf. A dialog box will pop up.
  6. Define the range: In the filter options box, select a range of values. A good choice is to set the maximum to 5. This tells Tableau to only keep rows where the Rank is 5 or less. Click OK.

Pros: This method gives you precise control over your filtering and works well in complex views with other table calculations. The RANK(), RANK_UNIQUE(), and other ranking functions offer even more nuanced ways to handle ties.

Cons: It's slightly more complex to set up. You have to be mindful of sorting and how the table calculation is being computed (its direction and scope, which can be edited via "Edit Table Calculation").

Bonus Pro Tip: Making Your Top N Dynamic with a Parameter

This is where your dashboards go from static to interactive. By combining a Parameter with a Set or a Rank calculation, you can let your audience decide if they want to see the Top 3, Top 5, or Top 10.

Let's adapt our Set method (Method 2) to build this.

Free PDF Guide

AI for Data Analysis Crash Course

Learn how to get AI to do data analysis for you — the best tools, prompts, and workflows to go from raw data to insights without writing a single line of code.

Step-by-Step Instructions:

  1. Create a Parameter:
  2. Connect the Parameter to your Set:
  3. Show the Parameter control: In the Data pane, find the "Select Top N" parameter, right-click on it, and choose Show Parameter.

A new control (a slider or a text box) will appear in your view. Now, when a user changes the value from 5 to 10, the view updates instantly to show the Top 10. This creates a much more engaging and user-driven experience.

Final Thoughts

You now have four solid methods for finding and visualizing Top N results in Tableau. The simple filter is great for quick analysis, while Sets, Index(), and Parameters unlock a greater degree of control, reusability, and interactivity for your dashboards. Choosing the right method depends on whether you need a quick static chart or a flexible, user-driven analysis.

Ultimately, these techniques are all about saving time and getting to insights faster. Here at our company, we built Graphed because we believe the path from data to decision should be as short as possible. Instead of spending hours learning calculation syntax or clicking through menus to create interactive filters, you can just ask in plain English: "Show me a chart of our top 5 products by sales" and get a live, interactive visualization in seconds. We automate the manual report-building so you can spend less time wrangling your tools and more time analyzing what your data is telling you.

Related Articles