Expert-led training for your team
How to Create Top N Parameter in Tableau

18 August 2023

How to Create Top N Parameter in Tableau

Allowing users to filter views to show the top or bottom N values is a common requirement in Tableau. Using parameters makes this flexible for end users.

In this article, you'll learn how to create Top N parameters in Tableau Desktop to dynamically rank and filter data. This article is part of our on-going blog series of useful 'how-to' guide in Tableau. The material from JBI Trainings is part of our tableau courses which can be accessed remotely or in person in London. Simply follow the link to participate in the training for you or your team.  Tableau Training London

Introduction to Top N Parameters

Giving dashboard users the ability to specify the number of top/bottom rows they want to see is extremely valuable for analytics.

For example, your executives may want to:

  • See the top 5 products by revenue each week.
  • Filter to the bottom 10 store locations by sales.
  • Only view the top 20 customers by order size.

By creating a Top N parameter, you can enable this flexible filtering without complex calculations.

We'll walk through how to set up ranking params using different Tableau techniques. Let's get started!

Top N Parameter with Filter

How to show the top n values in Tableau - TAR Solutions

The easiest way is to base your parameter on the Top N Filter.


  1. Create a number parameter called "Top N" that defaults to 10.
  2. Drag your dimension to Filters.
  3. Click the Top N Filter icon.
  4. Set it to use the "Top N" parameter value.

Now users can change the parameter to rank top and bottom values dynamically.

Sets for Top N and Others - Tableau

Customising the Parameter

You can allow additional configurations like:

  • Sort - Top vs Bottom radiobutton parameter.
  • Measure - Dropdown parameter to pick rank field.
  • Ties - Checkbox to include ties.

Top N Parameter with Table Calculation

For more flexibility, base your parameter on a table calculation rank measure.


  1. Create a calculated field such as RANK([Sales])
  2. Build a parameter using a formula like <[Top N]>
  3. Filter the rank field less than or equal to the parameter.

Table calculations allow custom rank logic like handling ties or percentages.

Top N Parameter with LOD Expression

For large data sets, use a level of detail (LOD) expression to optimize performance.


  1. Create a fixed LOD using TOPN based on a parameter.
  2. The LOD computes the rank during extract refresh.
  3. No additional filters needed.

LODs lead to fast ranking with live connection flexibility.

Let Users Analyse Top Values

Exposing a parameter makes it easy for consumers to:

  • Search for patterns and outliers in top and bottom values.
  • Monitor KPIs like top customers or worst products.
  • Analyse changes and trends in rankings.

Careful parameter design provides user flexibility without complex data manipulation.


To recap, you can enable top and bottom filtering in Tableau with:

  • Filters - Quick Top N config using a parameter.
  • Table calcs - Custom rank logic with parameters.
  • LODs - Fast ranking on large data sources.

Top N parameters create interactive dashboards for data analysis. Users gain insights by dynamically ranking and filtering data.

Now you have the skills to build flexible top and bottom filtering in Tableau!

This article is part of our on-going series of Tableau guides. You might like to check out how to show top n in tableau or how to query in tableau

About the author: Daniel West
Tech Blogger & Researcher for JBI Training

+44 (0)20 8446 7555

[email protected]



Copyright © 2023 JBI Training. All Rights Reserved.
JB International Training Ltd  -  Company Registration Number: 08458005
Registered Address: Wohl Enterprise Hub, 2B Redbourne Avenue, London, N3 2BS

Modern Slavery Statement & Corporate Policies | Terms & Conditions | Contact Us


Rust training course                                                                          React training course

Threat modelling training course   Python for data analysts training course

Power BI training course                                   Machine Learning training course

Spring Boot Microservices training course              Terraform training course

Kubernetes training course                                                            C++ training course

Power Automate training course                               Clean Code training course