How to Create a Top N Filter in Tableau

Cody Schneider8 min read

Need to see your top 10 best-selling products, your top 5 revenue-generating ad campaigns, or your top 3 underperforming sales regions? Filtering your data to show only the “Top N” performers is one of the most common and powerful analysis techniques. This article walks you through exactly how to create a dynamic Top N filter in Tableau, from the simple, built-in method to more flexible advanced techniques.

GraphedGraphed

Still Building Reports Manually?

Watch how growth teams are getting answers in seconds — not days.

Watch Graphed demo video

Why a Top N Filter is So Useful

In business analytics, not all data points are created equal. Often, a small number of items are responsible for a large portion of your results - this is known as the Pareto principle, or the 80/20 rule. A Top N filter helps you cut through the noise and focus your attention on what truly matters. Instead of scrolling through hundreds of rows, you can instantly see:

  • Which products are driving the most sales.
  • Which marketing channels have the highest conversion rates.
  • Which sales representatives are closing the most deals.
  • Which landing pages are receiving the most traffic.

Creating an interactive Top N filter gives you and your team the power to adjust the "N" - whether it's the Top 5, Top 10, or Top 20 - on the fly, making your dashboards more dynamic and exploratory.

Method 1: Creating a Simple Top N Filter Using Parameters

The most straightforward method uses Tableau's built-in filter options combined with a parameter. This gives the end-user a simple text box or slider to control how many items they see. We'll use the Sample - Superstore data and imagine we want to find our top-selling Sub-Categories.

Step 1: Build a Basic Visualization

First, create a simple bar chart to visualize sales by sub-category.

  1. Drag the Sub-Category dimension to the Columns shelf.
  2. Drag the Sales measure to the Rows shelf.
  3. Click the "Sort Descending" icon in the toolbar so the highest-selling sub-categories are on the left.

Your view should now show all sub-categories sorted from highest to lowest sales.

GraphedGraphed

Still Building Reports Manually?

Watch how growth teams are getting answers in seconds — not days.

Watch Graphed demo video

Step 2: Create a Parameter for 'N'

A parameter is a user-controlled variable that can be used in calculations and filters. By creating one for 'N', users can decide how many top items they want to see.

  1. In the Data Pane on the left, click the small dropdown arrow next to the search bar and select Create Parameter.
  2. In the dialog box that appears, set up your parameter like this:
  3. Click OK. You'll now see your new parameter under the "Parameters" section in the bottom left. Right-click on it and select Show Parameter to make it visible on your dashboard.

Step 3: Apply the Filter to Your Dimension

Now, let's link this parameter to a filter on the Sub-Category dimension.

  1. From the Data pane, drag the Sub-Category dimension onto the Filters card.
  2. A filter dialog box will appear. Go to the Top tab at the top.
  3. Select the option By field.
  4. The default dropdown box will likely say "Top 10...". Click on the "10". This reveals a dropdown menu where you can find and select the parameter you just created: Top N Sub-Categories.
  5. Finally, ensure the second dropdown correctly specifies the measure and aggregation for ranking (e.g., Sum of Sales).

Click Apply and then OK. Voila! Your chart now only shows the number of sub-categories defined by your parameter. You can interact with the parameter control on your dashboard (typing a new number or using the slider) and the visualization will update instantly.

Method 2: Advanced Top N Filtering with the INDEX() Function

The first method is great for simple charts, but sometimes you need more control, especially when working with complex table calculations. Using the INDEX() function, a table calculation that returns the position of each row, gives you a more robust filtering mechanism.

The primary advantage of this method is that it filters the view without removing the underlying data from the table's context. This is crucial if you need other calculations (like percent of total) to compute correctly based on all data, not just the filtered subset.

Step 1: Set Up Your View and Parameter

Start with the same sorted bar chart as before (Sub-Category by Sales). You can also use the same "Top N Sub-Categories" parameter we already created.

GraphedGraphed

Still Building Reports Manually?

Watch how growth teams are getting answers in seconds — not days.

Watch Graphed demo video

Step 2: Create the Filtering Calculation

We'll create a calculated field that returns 'True' if a sub-category is within our desired Top N range and 'False' otherwise.

  1. Go to Analysis > Create Calculated Field.
  2. Name the calculation something like "Top N Filter".
  3. Enter the following formula:

INDEX() <= [Top N Sub-Categories]

  1. Click OK.

This formula checks if the index (or rank) of each row is less than or equal to the number specified in our parameter. It's a simple boolean (True/False) calculation.

Step 3: Apply the Calculation to a Table

To correctly configure a table calculation like INDEX(), it's easiest to work with a text table first.

  1. Convert your visualization to a text table by selecting Show Me in the top right and choosing the table icon.
  2. Drag Sub-Category to the Rows shelf and Sales to the Text card on the Marks card. Sort Sub-Category by Sales descending.
  3. Now, drag your Top N Filter calculation from the Data Pane onto the Filters card.
  4. Select True and click 'OK'.

At first, this might not work as expected. This is because we haven't told Tableau how to compute the index. By default, it might be ranking alphabetically instead of by sales.

Step 4: Configure the Table Calculation

This is the most important step for this method. You need to tell the Top N Filter to sort by Sales descending before assigning the index rank.

  1. With the Top N Filter pill still on the Filters Card, right-click it and select Edit Table Calculation.
  2. (Newer versions of Tableau make this even easier) Alternatively, right-click the pill and select Compute Using.
  3. Here, you get several options. The simplest choice is to choose Specific Dimensions. Make sure Sub-Category is checked. The key is in the sorting: set the Sort order to be based on Sales using Sum as the aggregation, in Descending order.

Your table will now correctly filter to display only the Top N sub-categories. You can now change your visualization back to a bar chart, and the filter will remain correctly configured.

Bonus Tip: How to Combine Everything Else into an 'Others' Category

A frequent request is to show the Top N performers and then group all the remaining items into a single "Others" category. This is incredibly useful for seeing how your top performers compare to the rest of the pack combined. This is best achieved using a Set.

Step 1: Create a Set

  1. In the Data Pane, right-click on the Sub-Category dimension and go to Create > Set.
  2. Give your set a name like "Top N Sub-Categories Set".
  3. In the dialog, go to the Top tab. Select By field and configure it exactly as you did in Method 1, using your "Top N Sub-Categories" parameter to control the ranking by Sum of Sales.
  4. Click OK. You've now created a dynamic set that always contains the members of your top group.
GraphedGraphed

Still Building Reports Manually?

Watch how growth teams are getting answers in seconds — not days.

Watch Graphed demo video

Step 2: Create a Grouping Calculation

Now, create a calculated field that uses this set to group your sub-categories.

  1. Create a new calculated field and name it "Top N + Others".
  2. Use this formula:

IF [Top N Sub-Categories Set] THEN [Sub-Category] ELSE "Others" END

  1. Click OK.

This formula checks if a sub-category is in your set. If it is, it shows its name, if not, it lumps it into the "Others" category.

Step 3: Build Your Final View

Use your new "Top N + Others" calculated field instead of the original "Sub-Category" dimension on the Columns or Rows shelf. Now, your chart will show your top performers as individual bars and a final bar for "Others," all controlled dynamically by your parameter.

Final Thoughts

Creating Top N filters is a fundamental skill in Tableau that transforms crowded visualizations into focused, actionable reports. Whether you are using the quick, built-in filter linked to a parameter or the more powerful combination of INDEX() and Sets, you now have the tools to highlight the most important drivers of your business performance.

Manually setting up filters, table calculations, and sets in tools like Tableau takes time and a bit of technical knowledge to get just right. At Graphed you, we approach this by leveraging natural language. You could simply ask, "Show me my top 10 products by sales this quarter as a bar chart," and we would instantly build a live, interactive visualization for you. The goal is to skip the setup and get straight to the insights, allowing anyone on your team to answer their own data questions in seconds.

Related Articles

How to Enable Data Analysis in Excel

Enable Excel's hidden data analysis tools with our step-by-step guide. Uncover trends, make forecasts, and turn raw numbers into actionable insights today!