Filter Top Percent Instead of Top N

Published: 17 May 2016
Last Modified Date: 08 Jan 2019


How to display the Top percentage of a field instead of the Top N.


Tableau Desktop


The following instructions can be reviewed in the workbook attached below.

Option 1

  1. Select Analysis > Create Calculated Field with a formula similar to the following: 

    INDEX() <= INT(SIZE()/5)

  2. Place the calculated field onto the Filters shelf and select True.

Note: Dividing by 5 will give the top 20 percent. This number can be adjusted to achieve the desired percentage. 

Option 2

  1. Create a parameter Top N% as a float between 0 and 1, step size 0.01. Optionally, format the display format to 'Percentage'
  2. Create a calculated field 'Top N percent' that returns the n-th percentile value of the data set:
     PERCENTILE([Sales],[Top N%]) 
  3. Create a calculated field 'Top N Filter' that filters out the Top N percent:
    [Sales] <= [Top N Percent]
  4. Use the field 'Top N filter' on the Filters shelf, selecting only 'True'.
See attached workbook Top n% sample.twbx for reference.
Did this article resolve the issue?