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
Slide the dimension Sub-category In the Lines,
Swipe the measurement sales In the Columns,
Order the data in descending order.
Step 2: Create a parameter
Click on the small arrow at the top of the Data panel and select Create a setting,
Name it Top N,
Choose the data type Entire,
In the allowed values, select Beach and include the following:
min: 1,
max: 10,
Increment size: 1,
Click on OK.
Step 3: Use the parameter
Right click on the parameter and select Show setting. For now, the parameter has no impact on the view,
Add field Sub-category in the filters,
Go to the tab Premiers and check By field,
Replace 10 with the parameter Top N,
Click on OK,
Test the setting.
Advice
Here are a few ways to create effective settings in Tableau Desktop:
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.
Show the settings only when relevant. An excessive number of visible parameters can disorient the user and affect the readability of your dashboard.