How to Do Top N in Tableau

Cody Schneider••7 min read

Displaying the "top N" items - like your top 10 best-selling products or top 5 most-visited pages - is one of the most common ways to bring focus to a cluttered dashboard. Instead of showing everything at once, a Top N filter cuts through the noise and directs attention to what's most important. This guide will walk you through several methods for creating Top N filters in Tableau, from a simple static filter to dynamic dashboards that let users explore the data themselves.

GraphedGraphed

Build AI Agents for Marketing

Build virtual employees that run your go to market. Connect your data sources, deploy autonomous agents, and grow your company.

Watch Graphed demo video

We'll cover the basic drag-and-drop method, a more flexible approach using parameters, how to group the remaining items into an "Other" category, and finally, an advanced technique for finding the Top N within each category.

The Basic Top N Filter

The quickest way to apply a Top N filter is directly on the Filters shelf. This method is perfect for static reports or when you know you will always want to see a specific number of items, like the top 10.

Let's use the Sample - Superstore data that comes with Tableau. Imagine you want to see the top 10 sub-categories by sales.

  1. Create your initial visualization. Drag Sub-Category to the Rows shelf and Sales to the Columns shelf. You’ll have a simple bar chart showing sales for all sub-categories. For clarity, sort it in descending order by clicking the sort icon in the toolbar.
  2. Add the dimension to the Filters shelf. Drag the Sub-Category pill from the Data pane over to the Filters shelf.
  3. Configure the Top N filter. A dialog box will appear. Go to the Top tab at the top of this box.
  4. Click OK. Your chart will now be filtered to show only the 10 sub-categories with the highest total sales.

This method works great for its simplicity, but it has a major drawback: it's not interactive. If a user wants to see the Top 5 or Top 15, they can't change it. For that, you need to use a parameter.

Free PDF · the crash course

AI Agents for Marketing Crash Course

Learn how to deploy AI marketing agents across your go-to-market — the best tools, prompts, and workflows to turn your data into autonomous execution without writing code.

Creating a Dynamic Top N Filter with a Parameter

Parameters give dashboard users control over the visualization. By creating a parameter, you can let your audience choose the "N" in "Top N" themselves, making your analysis far more interactive and insightful.

We'll use a combination of a parameter and a set to accomplish this.

Step 1: Create the Parameter

The parameter will be the user-facing control that lets them input a number.

  • In the Data pane (the sidebar on the left), click the small dropdown arrow at the top and select Create Parameter....
  • A configuration window will pop up. Fill it out as follows:
  • Click OK. You will now see your new [Top N Selector] parameter at the bottom of the Data pane.
  • To make it usable, right-click on the parameter and select Show Parameter. A small control card will appear on the right side of your view, allowing you to type in a number or use a slider. For now, it doesn't do anything – we have to connect it to our data.

Step 2: Create a Set Linked to the Parameter

A "set" in Tableau is a custom field that defines a subset of your data. We're going to create a set of Sub-Categories, and instead of defining it with a fixed number, we'll use the parameter we just created.

  • In the Data pane, find your dimension. In our case, it's Sub-Category.
  • Right-click on Sub-Category and go to Create > Set....
  • Name your set, for example, Top N Sub-Categories Set.
  • In the dialog box, navigate to the Top tab.
  • Select By field.
  • Here’s the important part: click the dropdown menu that currently says "10" and select your parameter, [Top N Selector].
  • Ensure the rest of the rule is correct (e.g., based on Sales and Sum). Click OK.

Step 3: Apply the Set to the Filter Shelf

Now all we have to do is use our dynamic set as the filter.

  • If you still have the old filter on the Filters shelf from the first method, right-click and remove it.
  • Drag your newly created [Top N Sub-Categories Set] from the bottom section of the Data pane to the Filters shelf.

That's it! Your view is now controlled by the "Top N Selector" parameter. Try moving the slider or typing in a new number. The chart will instantly update to show the Top 3, Top 5, Top 12, or whatever number you select. This creates a much more engaging and useful dashboard for your end-users.

GraphedGraphed

Build AI Agents for Marketing

Build virtual employees that run your go to market. Connect your data sources, deploy autonomous agents, and grow your company.

Watch Graphed demo video

Grouping Bottom Results into an "Other" Category

Sometimes, you want to highlight the top performers but still account for the total. A great way to do this is to show the Top N items individually and then group all the remaining items into a single "Other" category. This provides context without cluttering the view.

To do this, we'll build on the parameter and set we created in the previous section.

  1. Ensure you have the Set and Parameter. Make sure your [Top N Selector] parameter and your [Top N Sub-Categories Set] are ready. The set is what classifies each sub-category as either being in the top group or not.
  2. Create a Calculated Field. This formula will create our new grouped labels.
  3. Update Your Visualization.

Now, as you adjust your "Top N Selector" parameter, your chart will neatly display the top items, and everything else will be cleanly aggregated into the "Other" bar, which will resize dynamically.

Finding the Top N Within Each Category

What if you need to perform a nested Top N analysis? For example, you might want to see the top 3 best-selling products within each product category. A simple filter won't work here because it would just find the overall top 3 products across all categories.

For this task, we need to use a table calculation, specifically RANK().

  1. Build the base visualization. Drag Category and then Product Name to the Rows shelf. Drag Sales to the Columns shelf. This gives you a very long list of all products, grouped by their category.
  2. Create the Rank calculation.
  3. Add the Rank to the view and configure it.

You should now see the products correctly ranked from 1 onwards inside of their respective categories.

  1. Filter by the rank. Now that the rank is working correctly, all that’s left is to filter it. Drag the [Product Rank within Category] pill from the Rows shelf over to the Filters shelf. Select a range, for example, from 1 to 3, and click OK.

Your view is now filtered to show only the Top 3 products within each category, a powerful insight that would be very difficult to get otherwise.

Free PDF · the crash course

AI Agents for Marketing Crash Course

Learn how to deploy AI marketing agents across your go-to-market — the best tools, prompts, and workflows to turn your data into autonomous execution without writing code.

Final Thoughts

Mastering the Top N calculation is a fundamental skill in Tableau that greatly enhances your ability to create focused and actionable reports. From the simplicity of a quick filter to the advanced control of restarting table calculations, Tableau provides a robust toolkit for highlighting your most important data points.

While these methods are powerful, learning the nuances of parameters, sets, and table calculations takes time and practice. At Graphed, we focus on shortening that learning curve. Instead of building these views manually, you can just ask questions in plain English - like "show me our top 10 products with sales over time" or "create a dashboard showing the top 5 campaigns by ROAS for the last 30 days." We built Graphed to translate your questions directly into the live, interactive dashboards you need, turning hours of analysis into a simple, 30-second conversation.

Related Articles