How to Build a Monthly Date Slider in Tableau
Sometimes in Tableau you have data at the monthly level and you want to use a date slider to filter it. Unfortunately the native date slider is too precise and operates at the daily level regardless of your aggregation level.
Monthly Date Slider in Tableau
Below is the expected behaviour of a monthly date slider, we can see the slider says January 2019 to December 2019 and that is reflected in the chart to the right.
However below is what happens when you move the slider, which adjusts at the daily level despite appearances of being monthly.
This isn’t good and we need a new method for creating date sliders at the monthly level.
To do this we can leverage numeric sliders instead and map our months to a numeric scale. We can do this with a simple calculation as follows:
Year([Date Field]) * 12 + Month([Date Field])
If we show this calculation as a dimension and then we can see we how the months map to the number scale, and if we put it on the filters tab as a continuous field, we can use it as a slider filter.
This Ordinal Month field is great for functionality but is meaningless to the end user so we need to create some custom labels for it. These will be done in a separate sheet and added above the slider when we make our final dashboard. The second sheet is configured like this, with the filter from the main chart applying to this sheet and showing the min and max dates in the range.
Now we can build the final dashboard with this labels sheet placed above the slider.
And there we have it, a date slider working at the monthly level.
The Information Lab (“TIL”) is a Gold resale partner of Tableau and Alteryx and offers related consulting and training across seven territories in Europe. TIL has offices in Ireland, the UK, Germany, France, Italy, the Netherlands and Luxembourg.
Clients include Coca-Cola, Close Bros Bank, PepsiCo, Deloitte, UBS, Solar Turbines & Boston Consulting Group. The Information Lab has worked with Close Brothers Bank to support their use of Alteryx for compliance with IFRS 9.
The Information Lab Ireland is at the forefront of creating a data-driven culture in Ireland. As part of our vision, we regularly host free events throughout the country to show how being data-driven can improve decision making and lead to a better understanding of the world around us.