By: Eric Parker
Eric Parker lives in Seattle and has been teaching Tableau and Alteryx for 5 years. He's helped thousands of students solve their most pressing problems. If you have a question, feel free to reach out to him directly via email.
In Tableau Desktop version 2020.1, Tableau addressed what has been the number one feature request for at least 6 years (as long as I’ve been using Tableau), dynamic parameters! You now have the ability to create a parameter and set it to automatically pull from a dimension or measure so the values update every time he workbook is opened (instead of needing a manual refresh every time the data updates).
Let’s look at an example. Imagine you have a dashboard that is set up to automatically show data from the last 14 days. You might utilize a relative date filter to set up a last 14 day filter or you might create a custom calculation.
I created a calculation for the sake of this exercise. I chose to do that because in the instance I am envisioning, the data might not update every day (i.e. the latest refresh may only have data from as recent as two days ago). Here’s what the calculation looks like.
The [Latest Date] field is a calculation I created to return the latest date in the data set. It looks like this.
Unsure what those curly braces are? Check out this post.
Each of the worksheets in the above dashboard have the [Last 14 Days] field on filter set to True.
This approach works great and will always show data from the most recent 14 days in the data set.
Now, imagine you get a request that users would like to be able to change the end date. They want it to default to the latest date, but they want the ability to pick the date to look at different time frames.
You can start by creating a parameter from your date field.
In creating the parameter, there are two things you can do to make it dynamic and increase its utilization.
On the right side, you can choose to have the values update every time the workbook is opened. On the drop down at the top, you can select a calculated field (like [Latest Date]) to automatically fulfill the current value every time the workbook is opened.
*Note; if no fields show up on the drop down for “Value when workbook opens:” that means none of the fields in your data source are a valid option. That could be due to data type or that you are trying to use a field that has multiple values.
The [Last 14 Days] calculation can now be updated to reference the parameter instead of the [Latest Date] calculation.
Notice the inclusion of the second row of logic. That is because the date difference (in days) between 11-30-19 and 11-29-19 is -1. If you don’t want unnecessary data included in your trend, you have to restrict the range to exactly the 14 days prior to the reference date.
The result is that if a new date is selected from the parameter, the data displaying in the dashboard updates.
More importantly, if the data is refreshed to include more current data…
(connecting to a new version of Sample - Superstore that has data through the end of 2019)
...and I save and close and reopen the workbook…
the range of values and current value in the parameter will automatically update!
I hope this walk-through has been a helpful tutorial on this new feature. If you found it useful, we would deeply appreciate it if you share with your team or a colleague!
Need help building your own calculations or customizations? Reach out or book an office hour and we’ll help you get rolling!