Alteryx Designer Desktop Discussions

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

Calculating the average time difference between orders,

SophieRawcliffe
5 - Atom

Hi community, 

 

My data has the customer ID and then the date they made a purchase. I want to work out the average time between purchases per customer but not sure where to start. Some customers have 1 purchase, some have a lot. 

 

Thanks for any help 

 

CustomerIDDate of transaction
1011850011/06/2024
1011850022/05/2023
1011850002/05/2024
1011850001/01/2023
1011850012/12/2023
1018954911/09/2023
1018954907/07/2024
1091552311/12/2023
1004953504/05/2022
1004953505/05/2022
1004953506/05/2022
1004953523/04/2024
2 REPLIES 2
ScottLewis
10 - Fireball

Attached should give you something to start with.

 

General Pattern for this sort of thing:

1. Format the data. Usually this means wrangling date formats.

2. Sort by group fields and then the thing you're comparing (in this case, Customer is a group, Date is the compare)

3. Use a multi-row field to get the change in the comparative, setting missing values to NULL

4. Use Summation to get the average. NULL after summation indicates a single entry, in this case a customer with one purchase.

griffinwelsh
12 - Quasar

@SophieRawcliffe take a look at the attached solution. You need to do the following:

1. Convert your date string to date time

2. Sort on customer id and date

3. Use the multi-row formula to calculate difference between dates. (make sure to group by customer)

4. Filter out nulls

5. Use the summarize tool to obtain the average time between orders

6. Find customers with only one order and union them back into the final result (optional)

Labels