To parameter or to filter? 

Well, that's an interesting question. Parameters have become an increasingly important part of Tableau over the years. Let’s not assume any prior knowledge for this post and recap some of the differences between parameters and filters before starting.

Filters

Parameters

Slices your data in time or dimension

Allows interactivity (via user input)

Single and multi-select

Single select

Can’t be used in calculations

Can be used in calculations

Are specific to a single data source*

Can be used cross data source

Available options originate from the data

Available options can be determined freely

                                                      *This would be possible across data sources with blending but that comes with its own set of limitations

The differences between the two functionalities are a good starting point for the use case that I’m about to present to you.

A use-case for parameters

Parameters allow more flexibility in your dashboard because you can incorporate them into your calculations. Let’s say that your client wishes to use one filter to slice multiple visuals in different ways.

For example, one visual should show the sales of that date, and another should show the sales of the same date of the previous year. We could apply the same thing on a month level with bar charts. But filters slice our data all in the same way, so how can we achieve such a thing?

What we’re looking for should look like this:

Tough cookie? Well not for parameters. As you know parameters can be used in calculations and that’s exactly how we will get to the solution. 

The nitty-gritty

In short, we’re going to bypass the limitation of filters by masking a parameter as a date filter. So without further ado, let’s just jump right into Tableau and create our date parameter.

You’ll want to select ‘Date’ as a data type to make this work. Furthermore, you can select ‘Range’ as allowable values to make Tableau get all the possible values from our date field (Order date in this case). Checking ‘When workbook opens’ makes it so that your parameter will dynamically update all the available values that are present.

Next up is where the magic happens. Creating parameters by itself does not get us anywhere. We need to incorporate them in a calculation with logic that gets us to where we want to go. So we will create a calculated field where we truncate the month of our parameter and make this equal to the same truncation of our date field. When we add this to our filter and select ‘True’, Tableau will show us all the data where this equation is true.

This means that we have successfully masked our parameter as a filter so that when we select a value in our parameter, it acts as a filter. So far this is just a more complicated way of adding a filter. So next up we replicate the previous step for our other visual to view the previous year’s results. To do this, we simply encapsulate the previous left-hand side of our calculated field in a DATEADD function with a “-1” interval in “year” to dial it back a year.

Rinse and repeat for the day-level visuals.

Let’s put them all together and check out the result as shown at the beginning of this post. Note that our KPIs change each time our date is changed but our bar charts only change when we’re in a different month. We would have needed multiple filter boxes to make this work without parameters.

Lastly, I have made my titles dynamic as well. If you’re interested to know how I did this, just drag a calculated field with (only) your parameter into the details marks card of your visual. Afterwards, you should be able to add it to your title from the insert menu


If you’re interested in how else you could customize your titles, make sure to check out Anoop’s blog post on this.

Discover other Tableau content

There are many other use cases for parameters so to make life easier for yourself, go ahead and check out what some of these geniuses have been able to achieve with this functionality:


Empower your organization with intuitive analytics

Tableau is designed to put the user first because data analysis should be about asking questions and not about learning software. With built-in visual best practices, Tableau enables limitless visual data exploration without interrupting the flow of analysis.

As the market-leading choice for modern business intelligence, the Tableau platform is known for taking any kind of data from almost any system and turning it into actionable insights with speed and ease. It’s as simple as dragging and dropping.

avatar_120x120_email_taner_kutluTaner Kutlu
Analytics Consultant
Biztory 

 

Let's talk about your data challenges

Author
Taner Kutlu

Taner Kutlu

Analytics Consultant

Read more articles of this author
Let's discuss your data challenges

Psssst... never miss out!

We'll keep you updated* with our latest knowledge and share our newest events (e.g. training, webinars).
 
*You receive max. two newsletters a month, and you can unsubscribe at any time.