Forum Discussion
ccolletti
Aug 24, 2023Copper Contributor
Finding the difference between more than 2 dates with a matching name from a different column
Hi All, I've been searching for a way to calculate the average difference between order dates for each of my customers. In my data I have one sheet with all my customers and their orders. Cur...
- Aug 24, 2023
To obtain for "Customer 1":
=LET( dates, FILTER(Purchase, Account = "Customer 1"), diff, IFERROR(DROP(dates, 1) - dates, ""), r, ROWS(diff), IF(r = 1, "-", AVERAGE(diff)) )
To do all 5 in one shot:
=LET( uAccount, SORT(UNIQUE(Account)), AvgDays, LAMBDA(a, v, LET( dates, FILTER(Purchase, Account = v), diff, IFERROR(DROP(dates, 1) - dates, ""), r, ROWS(diff), result, IF(r = 1, " - ", AVERAGE(diff)), VSTACK(a, HSTACK(v, result)) ) ), REDUCE({"Account", "Avg days"}, uAccount, AvgDays) )
ccolletti
Aug 24, 2023Copper Contributor
Thank you so much Patrick2788! That worked for me!
I used the first one to get the average for each customer individually.
I used the first one to get the average for each customer individually.
Patrick2788
Aug 24, 2023Silver Contributor
Glad it worked. You're welcome!