BITS OF TABLEAU

Filter Dates Using Parameters in Tableau Dashboards

The Simplest Way to Filter Dates in Tableau

Sharon Regina
CodeX

--

Have you ever felt that the Date -> Edit Filter option is too limited and impractical? Or the range of dates slider is hard to customize?

Visualization Without Date Filters from Parameters by Author

No worries! This time, I will share a tutorial on how to make ‘Start Date’, ‘End Date’, and ‘Filter Date By’ buttons that can filter the entire dashboard by the selected date variable. By the end of this read, you’ll know how to build a user-friendly and highly customizable date filter using parameters!

Tableau’s Superstore dataset is used to visualize Superstore’s Sales Over Time, color-coded based on the Category.

Let’s begin :).

  1. Drag the needed Measures to Columns and Dimensions to Rows.

The Ship Date variable will be used here as the date variable. Notice that the date variable must be continuous, not the default discrete variable, to visualize the change over time.

Visualization without Parameters by Author

2. Tip: Tableau has a date feature where users can change between date parts easily by clicking the ‘-’ & ‘+’ buttons on the left.

From the least to most granular Ship Date variable date part, Year -> Quarter -> Month -> Week -> Day.

Tableau’s date part feature by Author

3. Create the ‘Start Date’, ‘End Date’, and ‘Filter Date By’ Parameters.

‘Start Date’ will act as the button determining the starting date, while ‘End Date’ determines the ending date.

‘Filter Date By’ will give dashboard users the flexibility to choose the method the dates are filtered, in this case, we make three options, ‘Start Date to End Date’, ‘Start Date to Yesterday’, and ‘Start Date to Today’ for demonstration.

Unfortunately, this Superstore Dataset only contains Ship Date up to 5 January 2021, hence, it cannot demonstrate ‘Today’ and ‘Yesterday’ clearly since it is not updated daily. However, the variety of options is fully customizable, for example, you can add ‘Today Only’, ‘Start Date to Last Month’, ‘Min Date to Max Date’, etc.

‘Start Date’, ‘End Date’, and ‘Filter Date By’ Parameters by Author

4. Create a @filter_date calculation to define the Parameters (make them work).

I like to use ‘@’ to differentiate parameter-defining calculations apart from other calculations. If you take a closer look at the calculation, you’ll notice that the upper code is to define the Start Date, whereas the bottom code is for the End Date. Note that this code is for the three options we put in the ‘Filter Date By’ parameter and you have to edit the code based on the options you put there, which can be mostly done utilizing Tableau’s date functions.

@filter_date calculation by Author

5. Drag @filter_date to the filter card and choose ‘True’ to activate the calculation for the sheet.

Editing @filter_date by Author

6. Custom Date Filter done! You can go ahead to try out the filter and design the dashboard.

Custom Date Dashboard design by Author

7. Additional Tip: You can change the ‘Current value’ of the ‘Start Date’ and ‘End Date’ Parameters to make the view more dynamic.

For example, I want the End Date Parameter to always be today’s date. So first, I have to create a calculated field that will give me today’s date as an output. Then, change the Current value of the Parameter to the Today Calculated Field I just created. The End Date will be automatically set to ‘22–05–2022’, the date this visualization is created, in the dashboard.

Editing Parameter’s current value by Author
Final Visualization Look by Author

Alright! This is the end of the Custom Date tutorial :) Don’t forget to explore Tableau’s various date functions, which can elevate your custom date filters even more.

For any inquiries, I can be contacted via LinkedIn. Hope this article can help you make more impactful data-driven decisions by applying custom date parameters in your visualizations :).

--

--

Sharon Regina
CodeX
Writer for

Business Intelligence enthusiast that wants to learn more by sharing my experiences and research. **Views expressed here are solely my own & not my employer’s.