Your 'time bucket' calculation would need to be based on NOW(). Also the dashboard would need to refresh to reset NOW() to the actual time now. Check this link about how to auto refresh. Auto Refreshing an Embedded View Using Meta Refresh | Tableau Software
You can use a calculation like DATEPART('hour',NOW())=DATEPART('hour',[Date Field]) to filter the report to match only hours that line up with the current hour of the day. You would then want to add in logic to filter which days to include in the report. Note this filter would not allow users to adjust which hour of the day they would like displayed and you would need to find a way to force the dashboard to refresh. If it was published on Tableau server find ways to refresh the view. If only on desktop you could try adding a pages option and setting it to loop.
Thanks, I've been told that the way we're going to display the dashboard will mean that the webpage will be refreshed every 30 seconds. This should eliminate the problem of needing the filter to change.
I'm somewhat new to Tableau (and am probably going about things in completely the wrong way); do you have any suggestions as to what I'd need to do to achieve what you've suggested?
Here's my calculation to group the times into buckets
IF [salestime] <13 THEN "AM"
ELSEIF [salestime] <19 THEN "Lunch"
ELSEIF [salestime] <24 THEN "PM"
I tried using the following to set my filter:
IF DATEPART('hour',NOW()) < 13 THEN "AM"
ELSEIF DATEPART('hour',NOW()) < 19 THEN "Lunch"
ELSEIF DATEPART('hour',NOW()) < 24 THEN "PM"
First best to clarify what you're trying to achieve. When the time is 00:00 to 12.59 you want to display the morning values, when the clock strikes 13.00 you want to display what?
Apologies, upon the clock striking 1pm, I'd like to only show "Lunch" values; even if this means nothing is shown.
Adapting your formula and this would assume you're filtering elsewhere for TODAY only.
I don't have access to Tableau right now so haven't been able to test this. These time filters aren't as simple as they first appear so no guarantee this will work, please test it. Place this on the filters shelf and set to 'show'
IF DATEPART('hour',NOW()) < 13 AND [salestime] <13 THEN "show"
ELSEIF DATEPART('hour',NOW()) < 19 AND [salestime] >= 13 AND [salestime] <19 THEN "show"
ELSEIF DATEPART('hour',NOW()) < 24 AND [salestime] >= 19 AND [salestime] <24 THEN "show"
This is exactly what I needed to use. Thank you so much, I’ve been banging my head against a wall about this all day.