Tableau Thursday Tutorial: Dynamic Top N Filter

This tutorial uses Tableau's sample dataset, Superstore. For instructions on how to access this dataset, please see this guide.

In Tableau, creating a dynamic "Top N" filter allows users to control how many top items (e.g., customers, products, categories) they want to display on a dashboard. Here's a step-by-step guide to create it:

1. Build the Base Chart

Step 1: Build a base chart
  • Drag the Product Name pill to Rows.
  • Drag the Sales pill to Columns.

2. Create Parameter

Step 2: Create Parameter
  • In the Data pane, click the drop-down arrow in the upper-right corner and select Create Parameter.
  • In the Create Parameter dialog box:
    • Set the Name to Top N Parameter.
    • Set the Data type to Integer.
    • Set the Current Value to 5 (this can be adjusted later).
    • Under Allowable values, select All.
    • Click the OK button.

3. Show the Parameter Control

Step 3: Show parameter control
  • In the Data pane, right-click on Top N Parameter (found at the bottom under Parameters) and select Show Parameter. This allows you to control the value dynamically.

4. Create the Filter

Step 4: Create the filter
  • Drag the Product Name pill to the Filters shelf.
  • In the Filter dialog box:
    • Go to the Top tab.
    • Select By Field.
    • Set the dropdowns to:
      • Top by Top N Parameter using Sales (Sum).
    • Click the OK button.

5. Test the Parameter

Step 5: Test parameter
  • In the Parameter Control Card (on the right of the viz), click the type-in field and enter the number 10 or any other N integer to update the chart dynamically.

Ensure that other filters in your worksheet are added to context so Tableau applies these filters to your data before calculating the Top N values.

Author:
Brenda Chavez
Powered by The Information Lab
1st Floor, 25 Watling Street, London, EC4M 9BR
Subscribe
to our Newsletter
Get the lastest news about The Data School and application tips
Subscribe now
© 2024 The Information Lab