Ads Top

An Apply Button for Your Parameters


Update April 20, 2020: I just learned that the brilliant Brian Moore wrote a very similar blog post last year, so please be sure to give it a read as well: Creating an “Apply” button for Parameters


One thing I always recommend to people is the use of Apply buttons on filters. I personally always add apply buttons when there are more than 2 or 3 options as it allows your user to select which items they wish to keep (or exclude) before the view refreshes. Without apply buttons, the view refreshes after every single selection, which can create a jarring experience for your user. And, if you have a lot of data or complex calculations, it can be a real performance drag since each refresh has to execute a new query.


But, this all falls apart when you’re using parameters to control some aspect of the viz because parameters do not have apply buttons. In many cases, this is okay, but in other scenarios, especially when the parameters work in concert with each other, it would be nice to be able to set all your parameters, then click Apply to update the view. With such a feature, we could avoid some of the very same problems our users encounter when we don’t use apply buttons on our filters.

Fortunately, we can use parameter actions to create an apply button for our parameters. To demonstrate this technique, I’m going to use this relatively simple workbook. On the right, we have a bar chart showing our most profitable customers and a bit of information about which sales have contributed most to their profitability. On the left, we have a slide out menu that contains four parameters.


Note: This slide out menu uses a technique developed by Kevin. You can learn about it here: Easily Create Collapsible Menus, Sheet Selectors, and Much More Using Navigation Buttons

The How Many Customers parameter defines how many customers are shown and is used in a Top N filter. The Show Top or Bottom parameter defines whether we’re going to show the most or least profitable. This is used in a calculated field which is then used in the same Top N filer. Finally, we have parameters for the start and end dates. These are used in a calculated field which is then used to filter the view.

The key to this set of parameters is that they are generally meant to work together. You might ask the question, "who are my 4 most profitable customers in 2018?" Without an apply button, you’d select “Top Customers” then Tableau would refresh the view; then you’d select 4 from the slider, then another refresh; etc. Each change requires a refresh. Ideally, we could set all the parameters and, only when we're ready, apply them to the view.

Creating an Apply Button
OK, so how we create this apply button? We’ll start by duplicating our parameters. We’ll suffix one set with “Input” and the other with “Final”.


We’ll update our calculations, Top N filters, etc. to use the Final versions of the parameters, but we’ll put the Input parameters on the viz itself. At this point, it will just have a dumb set of parameters that do nothing.

Next, we’ll create a worksheet to act as a button. For mine, I created a simple button image using PowerPoint. I then used that image as a custom shape.


So that we can use this button to pass the values of the input parameters within a parameter action, we also need to place each of those parameters on the detail card, as shown above.

Now we’ll place this button on our dashboard.


Finally, we’ll create 4 parameter actions—one for each parameter. Each will take the value from the Input parameter and move it to the Final parameter. For example, here’s the parameter action for Start Date.


Now, when you click the Apply button, it will trigger all of the parameter actions at the same time, forcing your Input parameter values into the Final parameters. The workbook will refresh once and you’ll get your result.


And that's all there is to it!! Thanks for reading. If you’d like to check out this workbook, it’s available on my Tableau Public page: Parameter Apply Button

Ken Flerlage, April 20, 2020


7 comments:

  1. Do you prefer to use parameters as filters, or the built in filter function?

    ReplyDelete
    Replies
    1. Generally speaking, I think it depends on the situation. If I can use filters, I use them, but sometimes we need something more than what can be done with filters. But, in most cases, I start with filters and only move to parameters if I really need to.

      Delete
  2. Hi, did you create the toggle sheet? How do you set up the relationship to prevent button?

    ReplyDelete
    Replies
    1. Might be easier to address this via email. flerlagekr@gmail.com

      Delete
  3. Is it possible to have filters and parameters on one apply button?

    ReplyDelete
  4. Pretty cool and simple - thanks for the article! This helped me. Also, instead of an image from powerpoint, I used a sheet with a parameter (since I needed a basic button).

    ReplyDelete

Powered by Blogger.