简体   繁体   English

Google Data Studio 在自定义日期过滤器默认范围中指示昨天时忽略周六和周日

[英]Google Data Studio Ignores Saturday and Sunday when Indicating Yesterday in Custom Date Filter Default Range

I am creating a report in Google Data Studio which pulls numerous days-worth of data;我正在 Google Data Studio 中创建一份报告,该报告提取了数天的数据; 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.我可以使用高级选项将默认日期范围设置为“昨天”(或今天减 1)。 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.因此,当我的报告在周二至周六执行时,“昨天”(或今天减 1)的日期范围有效,但如果在周日或周一执行,则不会显示任何数据。

Is there a way Data Studio can handle this scenario? Data Studio 有没有办法处理这种情况? Essentially, I need "Yesterday" to ignore weekend days of Saturday and Sunday.本质上,我需要“昨天”来忽略周六和周日的周末。

So I got this answer from Google Support所以我从谷歌支持那里得到了这个答案

  1. Click the pencil icon to edit your data source单击铅笔图标以编辑您的数据源
  2. Duplicate your date field and change the type to Day of Week复制您的日期字段并将类型更改为星期几
  3. Add a control (type Drop-down list) to your dashboard.将控件(类型下拉列表)添加到仪表板。
  4. Set Date range dimension to Date将日期范围维度设置为日期
  5. Set Dimension to Day of Week and default selection 1,2,3,4,5.将维度设置为星期几,默认选择 1、2、3、4、5。

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它基本上使星期五和星期四看起来像昨天和前一天的星期一和星期五的前一天星期二,因此您可以将自定义数据范围与昨天上一期间过滤器一起使用

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM