示例表:
Date, CustomerID
2020-01-01,a
2020-01-01,b
2020-01-01,c
2020-01-02,a
[...]
2020-01-31,a
2020-01-31,b
2020-01-31,c
2020-01-31,d
2020-02-01,a
2020-02-01,b
[...]
Run Code Online (Sandbox Code Playgroud)
假设我将日期范围设置为 2020-01-01 - 2020-01-31。
我想计算以下之间的差异:
(count_distinct(CustomerId) with filter Date=2020-01-01) - (count_distinct(CustomerId) with filter Date=2020-01-31) and get the result 1.
Run Code Online (Sandbox Code Playgroud)
我已经尝试MAX(Date)过MIN(Date),但是我找不到将其用作过滤器的方法。
当连接到大查询时,我可以使用@DS_START_DATE,但我想在数据工作室内部使用它。
这可能吗?谢谢。