Back

Explore Courses Blog Tutorials Interview Questions
0 votes
1 view
in BI by (17.6k points)

I want to set the default range on a date filter to show me the last 10 days - so basically looking at the lastDate (max date) in the data and default filtering only on the last 10 days (maxDate - 10)

How it looks now:

enter image description here

I still would want to see the entire range bar on the dashboard and give the user the ability to modify the selected range if he wants to. The maxDate changes after every data refresh so it has to be some sort of a condition that is applied to the filter.

How I want it to look (by default after every refresh of data - new dates coming in):

enter image description here

Any suggestions on how this can be done? I know I can use the relative date and show the data for the last 10 days but that would modify the filter and create a drop-down which I don't want.

Any suggestions are welcome!

1 Answer

0 votes
by (47.2k points)

  • This can be simply achieved by following this  simple approach :

  • Create an integer-valued parameter with a range from 1 to some max you choose, say 100. Call it to say num_days.

  • Show the parameter control on your dashboard as a slider, and give it a nice title like "Number of days to display"

  • You can create a boolean calculated field called Within_Day_Range defined as:
    datediff('minute', [My_Date_Field], now()) < [num_days] * 24 * 60

  • You need to put Within_Day_Range on the filter shelf and select the value true.

  • This lets the user easily select how many days in the past to include, and works to the granularity of minutes (i.e. the last two days really means the last 48 hours, not starting at midnight yesterday). Now, Adjust the calculated field if you want different behavior.

  • The main drawback of this approach as described so far is that it doesn't display the earliest date possible in the database because that is filtered out. Quick filters do an initial query to get the bounds, which has a performance cost -- so using the approach described here can avoid that query and thus load faster.

  • If you really need that information on your dashboard, you could create a different worksheet to get just the min([My_Date_Field]) and display that near your parameter control.

Further, enroll for an online training course to clear the Tableau Desktop Specialist Certification exam. I would recommend this Tableau Training online by Intellipaat. 

Related questions

0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
Welcome to Intellipaat Community. Get your technical queries answered by top developers!

28.4k questions

29.7k answers

500 comments

94.2k users

Browse Categories

...