Count number of rows depending on a condition
Anne_P
Registered Posts: 2 ✭
Hello,
I would like to increment the number of rows group by some variables only when a condition between a date and its lag is true. The idea is the following :
if it is the first time we encounter an id, then var = 1;
else if id = id_lag and dat - dat_lag > 30 then var = var +1 ;
I try to do this with a window recipe but I can't. Can you help me please ?
Tagged:
Answers
-
Turribeach Dataiku DSS Core Designer, Neuron, Dataiku DSS Adv Designer, Registered, Neuron 2023 Posts: 1,993 Neuron
Please attach a small sample dataset and how you want the output column to look like.
-
Sorry, I didn't attached my example :
my group variables : code_reg and id
var = 2 in line 4 and 7 because the difference between dat_evnm and dat_evnm_lag > 30 -
Turribeach Dataiku DSS Core Designer, Neuron, Dataiku DSS Adv Designer, Registered, Neuron 2023 Posts: 1,993 Neuron
Can you please attach an actual Excel file? I can't load rows from an image…