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.
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
Do you prefer to use parameters as filters, or the built in filter function?
ReplyDeleteGenerally 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.
DeleteHi, did you create the toggle sheet? How do you set up the relationship to prevent button?
ReplyDeleteMight be easier to address this via email. flerlagekr@gmail.com
DeleteHi, even I'm wondering the same.. Can I reach out to you regarding this?
DeleteYes, of course.
DeleteIs it possible to have filters and parameters on one apply button?
ReplyDeleteUnfortunately, no.
DeletePretty 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).
ReplyDeleteHi Ken,
ReplyDeleteCan i please find out whether is there a way to apply this to multiple workbooks within a dashboard from multiple data source? Or do we need to create multiple Apply buttons to work?
Thanks
Parameters are not data source specific, so this can be made to work for multiple data sources.
DeleteHi Ken,
ReplyDeleteI also was confused by the toggle sheet another user mentioned. Can I email you?
Yes, of course.
DeleteHi,
ReplyDeleteThanks for this! Really helpful!
I have a question: I have 3 filters and a parameter in my dashboard. Is it possible to have a single apply button for all them ?
Thanks
Puneet Gupta
This technique only works for parameters. I'm not aware of a good way to do this with filters.
DeleteYou can add the filters from the apply worksheet to a 'filter /parameters container' and that as a filter action for the rest of the dashboard along with the parameter action discussed here.. this has worked for me.. the only issue i have is to reset the parameter for another choice you have to deselect the 'apply' and reselect again
DeleteHey can you help me out how you did top 5 Customers with details on it like Profit and Sales# etc ..
ReplyDeleteSure, please send me an email. flerlagekr@gmail.com
DeleteYou can also download the workbook from Tableau Public.
DeleteHi,
ReplyDeleteI tried this method and it is working as well. Thank you for this trick. But I am using live connection. Whenever I am changing values of each parameter, it is taking time for executing query(Pop up 'Executing query' is appearing) then at the end click on 'Apply' button is reflecting all the changed values in visualization. Is it like changing the values in parameter is bringing relevant data from datasource into the dashboard but only after clicking 'Apply' button it is getting displayed in the visualization? If that is the case then I want to bring the relevant data from datasource only after clicking the 'Apply' button? Is there a way for this?
What's the driver for using a live connection?
DeleteIt's Snowflake ODBC
DeleteSorry what I meant was why are you using a live connection? Can you use an extract instead?
DeleteI am working on larger data set and the requirement is when I select values in my parameters only those values should be fetched from data source
ReplyDeleteThank you for the great explanation Ken!
ReplyDeleteI have a problem with the "click" on the button. If i click on the Button in the "Apply button"-Sheet everything works. But if i click on the same button on the dashboard nothing happens. you maybe know what the reason is?
Best regards
That's correct. I didn't go into this in the blog, but what's happening is that this button is just a mark on a sheet. When you click a mark, it gets selected. You have to use a technique to force the button to be deselected automatically. I'd recommend trying the method at the end of this blog by Ryan Sleeper: https://playfairdata.com/how-to-make-a-boolean-toggle-in-tableau/. I've found that there are times when this doesn't quite work, so if you run into that, send me an email and I can provide some alternatives. My email is flerlagekr@gmail.com
DeleteHi Ken,
ReplyDeleteInstead of clicking on Apply button of each filter, do you have any similar workaround for all filters?
Thanks
Unfortunately, no.
DeleteHi Ken, in my dashboard I have filters along with parameters. I want to use single apply button for them. Pls. Suggest.
ReplyDeleteI don't have a solution for that, unfortunately.
DeleteHi Ken, Does this work with live connection dashboards?
ReplyDeleteYes
DeleteI tried this logic in both extract and live connection. In Extract, it's working fine but in live connection, it's not. My input parameters are client, start date, and end date which I have called them in Custom SQL Query. The database I am using is Vertica. But when I finally give the input for a client in the client parameter and click anywhere outside the report the query is getting executed before selecting the start and end date. Is this a known issue for live connection dashboards ?
ReplyDeleteI'd need to see a workbook, unfortunately. Any chance you could email me? flerlagekr@gmail.com
DeleteSorry I cannot do that.
DeleteFor example my custom sql query will be :
Delete"select client,order_id,total_order,avg_order
from test t
where t.client =
and t.date >=
and t.date < "
Any of these three parameters should be hit only after clicking the apply button, But it's not happening in my case.
Hi Ken
ReplyDeleteI have used this APPLY Button for both Filters and parameters in my dashboard.
When I select a value that is not appropriate to the view, the APPLY button gets disabled. Pls let mw know how to rectify this, I have selected 'all values in the Context' under filter settings.
I'd need to know more. Can you email me? flerlagekr@gmail.com
DeleteHi Ken, I too had a similar issue with Apply Button. I had sent the mail which is mentioned in above comment
Delete