Reputation: 107
I am creating a report in Google Data Studio which pulls numerous days-worth of data; however, I want the report's date filter to default the initial presentation data to ONLY display the previous BUSINESS DAY's data.
I can set the default date range to "Yesterday" (or today minus 1) using the Advanced option. That get's me part of the way; however, the overnight, batch data I received each is based on activity conducted the prior weekday (Monday-Friday).
So, a date range of "Yesterday" (or today minus 1) works find when my report is executed on a Tuesday through Saturday, but if it is executed on a Sunday or a Monday, no data will show.
Is there a way Data Studio can handle this scenario? Essentially, I need "Yesterday" to ignore weekend days of Saturday and Sunday.
Upvotes: 1
Views: 3582
Reputation: 1
You can do something like this:
CASE
WHEN (date_field = DATETIME_SUB(current_date(), INTERVAL 4 day) AND weekday(current_date()) = 1) THEN DATE(DATETIME_SUB(current_date(), INTERVAL 2 day))
WHEN (date_field = DATETIME_SUB(current_date(), INTERVAL 3 day) AND weekday(current_date()) = 1) THEN DATE(DATETIME_SUB(current_date(), INTERVAL 1 day))
WHEN (date_field = DATETIME_SUB(current_date(), INTERVAL 1 day) AND weekday(current_date()) = 2) THEN date_field
WHEN (date_field = DATETIME_SUB(current_date(), INTERVAL 3 day) AND weekday(current_date()) = 2) THEN DATE(DATETIME_SUB(current_date(), INTERVAL 2 day))
ELSE null
END
and then use that as your date range dimension. It basically makes Fridays and Thursdays look like yesterday and the day before on Monday and Friday the day before for Tuesday so you can use custom data ranges with the yesterday and previous period filters
Upvotes: 0
Reputation: 11
So I got this answer from Google Support
Upvotes: 1