Advent of Code is back! Unwrap daily challenges to sharpen your Alteryx skills and earn badges along the way! Learn more now.

Alteryx Designer Desktop Discussions

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

Calculating DateDiff and Days Since

RUSA
7 - Meteor

I need to calculate the number of days since the last order date for a set of customers in 2 ways.

 

1. "Days Since Last Order". The days between the PeriodEndDate on the current row and the PeriodEndDate of the most previous period in which the same customer made an order.

 

2. "Days Since Last Order From Today". The days between the maximum PeriodEndDate that the customer appears in the table and Today.

 

Attached is an attempted workflow. I wasn't able to get DateTimeDiff() to work at all, so I'm guessing there is a lot of operator error here.

 

CustomerIDOrderCountQtyRevenuePeriodEndDateDESIRED Days Since Last OrderDESIRED  Max_OrderPeriodEndDESIRED Days Since Last Order From Today
10024601/28/201804/26/2018843
10024602/25/2018284/26/2018843
1005101504/26/2018604/26/2018843
15004602/25/201804/26/2018843
1505101504/26/2018604/26/2018843
20036901/28/201801/28/2018931
3005101501/28/201801/28/2018931
30024602/25/2018282/25/2018903
3000101504/26/2018602/25/2018903
40012301/28/201804/26/2018843
40036902/25/2018284/26/2018843
40024604/26/2018604/26/2018843
500481201/28/201804/26/2018843
500481202/25/2018284/26/2018843
5005101504/26/2018604/26/2018843
60012301/28/201804/26/2018843
600481204/26/2018884/26/2018843
650081202/25/2018000
7005101501/28/201802/25/2018903
70036902/25/2018282/25/2018903
800481201/28/201804/26/2018843
80036904/26/2018884/26/2018843
9000101502/25/201804/26/2018843
900481204/26/2018604/26/2018843
100012301/28/201802/25/2018903
10005101502/25/2018282/25/2018903

 

 

1 REPLY 1
wwatson
12 - Quasar

you'll need to convert your period end date into a date type using a datetimeparse tool or a %m/%d/%Y. Then datetimediff should work.

Labels