Showing Top and Bottom N Per Category

Published: 16 Aug 2017
Last Modified Date: 03 Jan 2019


How to show top and bottom N per category.


  • Tableau Desktop


The attached example workbook uses the example data set Superstore to demonstrate the following instructions:

  1. Create a calculated field with a name like "Top & Bottom N Filter" with a calculation similar to the following:

    RANK( SUM( [Sales] ), 'desc' ) <= [N Parameter]


    RANK( SUM( [Sales] ), 'asc' ) <= [N Parameter]

    The above calculation returns a value of true if SUM( [Sales] ) is the highest N ranking sub-categories for either largest first or smallest first.

  2. Drag [Top & Bottom N Filter] to the Filters shelf and click OK to close the Filter dialog.

  3. Right-click [Top & Bottom N Filter] on the Filters shelf and select Compute using > Pane (Down).

  4. In the Filter dialog, check True and click OK.

Did this article resolve the issue?