0
0
Tableaubi_tool~7 mins

Parameter for top N control in Tableau - Step-by-Step Guide

Choose your learning style9 modes available
Introduction
This feature lets you create a control to show only the top N items in your Tableau view. It helps you focus on the most important data points by letting users choose how many top items to see.
When you want to let users pick how many top-selling products to display on a sales dashboard
When you need to show the top N customers by revenue but want the number to be flexible
When your report should highlight the top N regions by profit and allow easy adjustment
When you want to reduce clutter by showing only the top N categories in a chart
When you want to compare the top N employees by performance dynamically
Steps
Step 1: Create a new parameter
- Data pane, right-click and select 'Create Parameter...'
A dialog box opens to define the parameter settings
💡 Name the parameter clearly, like 'Top N Selector'
Step 2: Set the parameter data type to Integer
- Parameter dialog box under 'Data type'
Parameter will accept whole numbers only
💡 Set a sensible range, for example minimum 1 and maximum 20
Step 3: Set allowable values to Range and define minimum, maximum, and step size
- Parameter dialog box under 'Allowable values'
Users can select a number within the defined range
💡 Step size of 1 lets users pick every number between min and max
Step 4: Click OK to create the parameter
- Parameter dialog box
Parameter appears in the Data pane under Parameters
Step 5: Create a calculated field to rank items
- Data pane, right-click and select 'Create Calculated Field...'
A dialog box opens to enter the formula
💡 Use RANK_UNIQUE or RANK_DENSE function based on your needs
Step 6: Enter the formula: RANK_UNIQUE(SUM([Measure]))
- Calculated Field dialog box
Calculated field ranks items by the chosen measure
💡 Replace [Measure] with your actual measure, like [Sales]
Step 7: Add a filter using the calculated rank field
- Filters shelf, drag the rank calculated field
Filter dialog opens to set filter condition
💡 Set filter condition to 'Less than or equal to' the parameter
Step 8: Set filter condition to 'Less than or equal to' and select the parameter
- Filter dialog box
Only top N items based on the parameter value will show
💡 Click OK to apply the filter
Step 9: Show the parameter control on the worksheet
- Right-click the parameter in Data pane and select 'Show Parameter Control'
Parameter control appears on the worksheet for user interaction
Before vs After
Before
Worksheet shows all 50 products with sales values in a bar chart
After
Worksheet shows only the top 5 products by sales, controlled by the parameter slider
Settings Reference
Parameter Data Type
📍 Parameter creation dialog
Defines the type of values the parameter can accept
Default: Integer
Allowable Values
📍 Parameter creation dialog
Controls what values users can select for the parameter
Default: All
Range Minimum and Maximum
📍 Parameter creation dialog when 'Range' is selected
Limits the parameter values to a specific numeric range
Default: Minimum 1, Maximum 20
Rank Calculation
📍 Calculated Field editor
Determines how items are ranked for filtering top N
Default: RANK_UNIQUE
Common Mistakes
Using a fixed number filter instead of a parameter
This does not allow users to change the top N dynamically
Create a parameter and use it in the filter condition for flexibility
Ranking without aggregation in the calculated field
Ranking raw data can give incorrect results because it needs aggregated values
Use aggregation like SUM or AVG inside the RANK function
Not showing the parameter control on the worksheet
Users cannot interact with the top N control without the parameter control visible
Right-click the parameter and select 'Show Parameter Control'
Summary
Parameters let users pick how many top items to display dynamically.
Use a calculated rank field with aggregation to filter top N items.
Always show the parameter control so users can adjust the top N value.