Alteryx Designer Desktop Discussions

Find answers, ask questions, and share expertise about Alteryx Designer Desktop and Intelligence Suite.

Figuring out the time between 1st and 2nd order

SophieRawcliffe
5 - Atom

I have a transactional log with one row representing one order. Customers can have multiple orders, or just a single one. I want to figure out the time difference between customers making their first order and 2nd order, ignoring the 3rd/4th/5th etc orders. Some customers have a single order so wouldn't apply, some have like 25 spread over 3 years.  I'm really struggling to figure this out, especially as Alteryx seems to be sorting my dates weirdly, despite me ensuring the order date column is recognised as datetime format. 

 

Current data:

Customer IDOrder Date
1000003930/05/2023
1000003901/06/2023
1000003908/06/2023
1000008520/11/2023
1000008502/04/2023

 

 

The goal:

Customer IDDays between 1st and 2nd transaction
100000399
10000085232
3 REPLIES 3
danilang
19 - Altair
19 - Altair

Hi @SophieRawcliffe 

 

What do you mean by Alteryx is sorting your dates weirdly?  If your dates are in YYYY-MM-DD and you're sorting by CustomerID and Date, the difference between the 1st and 2nd record for each customer will give you what you're looking for.  

 

BTW for customer 10000039, the difference between the 1st and 2nd order is only 3 days(2 if you're exclusive of the first date). May 30-Jun 01  

 

Dan

Raj
16 - Nebula

@SophieRawcliffe 
please find the workflow attached
mark done if solved.

Raj
16 - Nebula

@danilang 
As per my understanding from the output data attached, he is trying to calculate the difference between 1st and last order.

Regards,

Raj

Labels