KNOWLEDGE BASE

Using a Top N Parameter to Filter a Table


Published: 13 Jul 2017
Last Modified Date: 22 Dec 2023

Question

How to display the top selected number of values in a dimension, based on a measure via a Top N parameter.

Environment

Tableau Desktop

Answer

Using the attached sample workbook which is downloadable from the link on the right side of this article, which makes use of the Sample - Superstore, follow these steps:
 
  1. Drag "Manufacturer "to the Rows shelf.
  2. Drag "Sales" to the Columns shelf.
  3. In the Data pane, click the drop down to the right of Dimensions and select Create Parameter.
  4. Name the Parameter (in this case "Top N").
  5. To the right of Allowable values:, in the Create Parameter window, select Range.
  6. Under Range of values, specify the Minimum, Maximum, and Step size desired.
  7. Click OK.
  8. Right click on "Manufacturer" in the Rows shelf and select Edit Filter.
  9. Navigate to the Top tab in the Filter window.
  10. Select By field:
    1. In the second drop down field to the left of "by", select "Top N"
    2. Ensure that the field to filter by (usually a measure) is specified, in case "Sales" as "Sum".
    3. Click OK.
  11. In the Data pane, under Parameters, right click on "Top N" and select Show Parameter Control.
  12. In the upper right corner of the view, there is now a "Top N" slider and number field. Changing this field by moving the slider, will change what is shown in the view.
  13. Lastly, in the toolbar at the top of the screen, click on the Descending button icon, which will sort SUM(Sales).
  14.  
The view is now showing the top manufacturers (selected by parameter), sorted by sales, from highest to lowest.
Did this article resolve the issue?