Parameter Actions #2: Creating a Top/Bottom N Parameter to Filter Dynamically

by Gloria Montgomery

Normal filters only allow a fixed number of values to be shown. For instance, a filter can be set to show the Top 10 bestselling products in a company. However, what if the user wants to be able to see the top 13 bestselling products? And then quickly shift and see the top 26? Well, using a normal filter doesn’t allow for that and in the example above, your user would be stuck with only ever seeing the top 10 products.  Sometimes this is fine, other times… not so much.

We can get around this process by using a parameter action which enables the user to select the Top N rows – where N equals the value they specify e.g. 13, 26, etc as mentioned above.

Here’s our initial view:

Step 1: Create a Parameter

  1. In the Data pane, click the drop-down arrow in the upper right corner and select ‘Create Parameter’.

In the Create Parameter dialog box, you will see the following properties:

  • Name: This parameter will appear as new field to the bottom left hand side of the data pane and will therefore require a name ( I’ve  gone with ‘How Many Records to Filter by?’).
  • Data type: In Tableau, Numerical values can be either integers or  An integer (more commonly called an int) is a number without a decimal point. A float is a floating-point number, which means it is a number that has a decimal place. Floats are used when more precision is needed. I’m going to go ahead and select the integer as I just have rounded whole numbers. 
  • Current Value: This is the value that your parameter will show by default on your view. I’ve left this as in on 100 (although in this case, as the subcategory list is quite small, go ahead and set it to a smaller amount – I should have done so on reflection).
  • Display Format: Here you can select the number format of your parameter, such as number, currency or percentage or leave it on the option Tableau will default to based on your data type.
  • Allowable Values: There are three options here that your parameter will display: all, list or range. The ‘All’ option will allow the user to enter any value of their choice; the ‘List’ option allows you to select a predetermined set of values you want the user to be able to select from and must correlated to a data field in your view but the Display as can be anything.  You can also select a range to limit the amount of choice available to the end user e.g. listing only the 1 to 16 bestselling product.

Step 2: Show Parameter Control

  1. Right click on the parameter on the bottom left of your screen and select ‘Show parameter control’. This will now appear on the top right hand side of the workbook as a dropdown. However you’ll notice this doesn’t actually do anything as we haven’t linked it up yet.

Step 3: Filtering

  1. Drag the product subcategory (or whatever dimension you are using) onto the filter shelf and select the following and click OK:

Your dynamic filter will now be active and ready to use. You can play around with it up clicking on the parameter control on the top right hand side of the workbook. Obviously the sub-category dimension that we’ve used is quite small, but you can imagine how handy this parameter filter becomes when dealing with many, many more rows.