vendredi 5 août 2016

Fire calculated field if same customer tableau

Greetings stackoverflow community; I have the following code to count days: function name: count_days:

DATEDIFF('day',LOOKUP(ATTR([visit_day]),-1),ATTR([visit_day])

and the outcome is the following:

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

I'm trying to write another function that fires the previous function only by customer, so the first day of one customer is not subtracted by the last day of the previous customer. The outcome should look like this:

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

I have try this code so far:

IF ATTR([customer_id]) != ATTR([customer_id])
THEN
NULL
ELSE
[count_days]
END

Any thoughts about this code to make it work?

Aucun commentaire:

Enregistrer un commentaire