0
0
Tableaubi_tool~10 mins

Parameter for top N control in Tableau - Cell-by-Cell Formula Trace

Choose your learning style9 modes available
Sample Data

Sales data for different products.

CellValue
A1Product
B1Sales
A2Apples
B2500
A3Bananas
B3300
A4Cherries
B4200
A5Dates
B5450
A6Elderberries
B6150
Formula Trace
RANK(SUM([Sales]), 'desc') <= [Top N Parameter]
Step 1: SUM([Sales]) for each product
Step 2: RANK(SUM([Sales]), 'desc')
Step 3: RANK(SUM([Sales]), 'desc') <= [Top N Parameter]
Cell Reference Map
    A          B
1 Product    Sales
2 Apples     500
3 Bananas    300
4 Cherries   200
5 Dates      450
6 Elderberries 150

[Top N Parameter] is a user input controlling how many top products to show.
The formula uses sales values from column B and a parameter controlling top N.
Result
    A          B       C
1 Product    Sales   Show?
2 Apples     500     TRUE
3 Dates      450     TRUE
4 Bananas    300     TRUE
5 Cherries   200     FALSE
6 Elderberries 150   FALSE
Only products ranked in the top N (3 here) show TRUE, controlling which products appear in the view.
Sheet Trace Quiz - 3 Questions
Test your understanding
What does the RANK function do in this formula?
AAssigns a position number based on sales descending
BCalculates the sum of sales
CFilters products with sales above average
DCounts the number of products
Key Result
Use RANK(SUM([Measure]), 'desc') <= [Parameter] to filter top N items dynamically.