我有以下代码来计算天数:
count_days :
DATEDIFF('day',LOOKUP(ATTR([visit_day]),-1),ATTR([visit_day])
结果如下:
customer_id | visit_day | count_days
customer 1 | 1/1/2016 |
customer 2 | 1/3/2016 | 2
customer 2 | 1/15/2016 | 12
customer 3 | 2/1/2016 | 16
customer 3 | 2/5/2016 | 4
我正在尝试编写另一个仅由客户触发上一个功能的功能,因此前一个客户的最后一天不会减去一个客户的第一天。结果应如下所示:
customer_id | visit_day | count_days
customer 1 | 1/1/2016 |
customer 2 | 1/3/2016 |
customer 2 | 1/15/2016 | 12
customer 3 | 2/1/2016 |
customer 3 | 2/5/2016 | 4
到目前为止,我已尝试过此代码:
IF ATTR([customer_id]) != ATTR([customer_id])
THEN
NULL
ELSE
[count_days]
END
有关此代码的任何想法,以使其工作?