How to build a “Top N” parameter in Tableau?

Preparation time : 10 minutes

Level : Intermediate

Objective: Create a dynamic “Top N” parameter in Tableau Desktop

You probably already know how to create a top 10 in Tableau, but do you know how to give the user the choice to define how many items to show in the rankings themselves? That's where a powerful Tableau tool comes in: settings. Parameters work like variables in math. Instead of setting a constant value, they make it possible to make this value dynamic and adjustable by the user.

In this article, we will see how to create a “Top N” parameter to offer an interactive and personalized experience to your users, by giving them the ability to define the size of the ranking to be displayed.

Required Data

  • 1 data table, Hypermarket (at the bottom of the Tableau Desktop login page),
  • 1 measure, for example Sales,
  • 1 dimension, such as Category.

Step 1: Build a basic chart

  1. Slide the dimension Sub-category In the Lines,
  2. Swipe the measurement sales In the Columns,
  3. Order the data in descending order.

Step 2: Create a parameter

  1. Click on the small arrow at the top of the Data panel and select Create a setting,
  2. Name it Top N,
  3. Choose the data type Entire,
  4. In the allowed values, select Beach and include the following:
  5. min: 1,
  6. max: 10,
  7. Increment size: 1,
  8. Click on OK.

Step 3: Use the parameter

  1. Right click on the parameter and select Show setting. For now, the parameter has no impact on the view,
  2. Add field Sub-category in the filters,
  3. Go to the tab Premiers and check By field,
  4. Replace 10 with the parameter Top N,
  5. Click on OK,
  6. Test the setting.

Advice

Here are a few ways to create effective settings in Tableau Desktop:

  1. Before creating a parameter, Clarify its purpose precisely. Each parameter should serve a specific need and improve the user experience, whether it's filtering data, adjusting values, or changing calculations.
  2. Show the settings only when relevant. An excessive number of visible parameters can disorient the user and affect the readability of your dashboard.