Sometimes less is more. Today I present you a way of filtering the current quarter, month and week using a single drop-down menu in Tableau. “But why would you do that if Tableau already has a date filter?”, you may ask, and the answer is in the first sentence of this paragraph.

The “relative date” filter in Tableau is very good. I use it every time and I love it. But sometimes it gives too many options, and for a specific visualization this could break things. Some dashboards are just meant to be seen by a certain date dimension.

The dashboard below, for example. It was made so the viewer can see how sales are in Canada by either the current quarter, month or week (there’s nothing preventing us to add “year” or “day”, by the way, but I’ll focus on these three).

You can see the parameter Date Selector at right, with the green background, that changes both visualizations and the title of the map. Give it a try.

So, how I made it in Tableau?

We will start by creating the parameter, but before that, I want you to understand how the function DATEPART works in Tableau:

how to filter date parts in tableau

Let’s keep in mind that we’ll use the date_part variable in our parameter. But how to filter date parts in Tableau?

Now let’s create the parameter named Date Selector with all the date parts we will want in our filter. The Data Type will be String and the allowable values will be in a List:

how to filter date parts in tableau

Good! Now we need to create a calculated field that will compare our parameter to the actual date:

The formula above states that the value of your parameter, for your specific date field, should be equal to the same date part of today. E.g. if the parameter is set to “Quarter” and today is 17th October 2016, it will say Q4 = Q4 (believing your dataset has data for the actual quarter).

You will notice that the result of this calculated field is a True/False dimension. To make your parameter work, just filter your new field to True and you’re all set!

Leave a Reply