Do you know how to create Dynamic TOP N in Tableau?
Follow along to the video or check out the steps below.
Let’s create a control to dynamically change the number of rows we want to see in our graph.
- Create a new parameter called “Top N” and set the type to Integer and the current value to 10.
Right click it and select Show Parameter.
- In a new Sheet, bring the Country/Region and the Product name to the Rows shelf.
Also, bring the Sales to the Columns shelf and to the Label
- Create a new calculated field called “Sales Rank” with the following formula:
Right click it and Convert to Discrete.
Bring it to the Rows shelf, between the two existing pills.
- Right click the Sales Rank pill in the Rows shelf and select Edit Table Calculation.
Compute using: Specific Dimensions
Country/Region and Product Name
At the level: Deepest
Restarting every: Country/region
- Create a new calculated field called “Show Me N” with the following formula:
[Sales Rank] <= [Top N]
- Put the newly created Show Me N in the Filter shelf and select the True value.
- Now you can format the numbers, change the colours and etc.