Average number of days between orders of a customer

taeyeon22

New Member
Joined
Dec 5, 2017
Messages
4
Hi there! I have a table like below:

Order DateBrandProduct IDCustomer IDSupermarketSales VolumeSales Value ($)
01/09/2016Company A3431345452Supermarket B510
02/09/2016Company A3524243784Supermarket B24
02/09/2016Company B3122345452Supermarket A12

<tbody>
</tbody>


I'd like to answer:
Average number of days between orders of a customer

How do I first group orders by each unique customer, find the days between their orders, then find the average?

Thanks for the help guys and gals!
 

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.
Won't the average number of days between orders for any one customer be the same as

=(MAX(Date)-MIN(Date))/(Count_of_dates-1)

so without sorting, assuming dates in column A, customer IDs in D then you can get that with this formula

=SUM(AGGREGATE({14,15},6,A$2:A$1000/(D$2:D$1000=F2),1)*{1,-1})/(COUNTIF(D$2:D$1000,F2)-1)

for a specific ID placed in cell F2
 
Upvote 0
Won't the average number of days between orders for any one customer be the same as

=(MAX(Date)-MIN(Date))/(Count_of_dates-1)

so without sorting, assuming dates in column A, customer IDs in D then you can get that with this formula

=SUM(AGGREGATE({14,15},6,A$2:A$1000/(D$2:D$1000=F2),1)*{1,-1})/(COUNTIF(D$2:D$1000,F2)-1)

for a specific ID placed in cell F2

Hi Barry,

Thanks for your answer. However, i don't quite understand the 'specific ID placed in cell F2' part. F2 is for the sales volume, but we're comparing it to column D for customer IDs?
 
Upvote 0
Sorry, I wasn't paying attention to your table. F2 could really be any blank cell.....so lets say you get a list of all customer IDs (if you don't have one already you could use Advanced filter on column D and get a unique list) and put that list in a blank column, e.g. column J, so if your list of IDs starts at J2 you could adjust the formula I suggested to this in K2:

=SUM(AGGREGATE({14,15},6,A$2:A$1000/(D$2:D$1000=J2),1)*{1,-1})/(COUNTIF(D$2:D$1000,J2)-1)

copy down and that should give you the average number of days between orders for each customer. If any customer has only 1 order then the above formula will give #DIV/0! error because there is no valid average in that case. If you want you can use IFERROR function to return another value, e.g.

=IFERROR(SUM(AGGREGATE({14,15},6,A$2:A$1000/(D$2:D$1000=J2),1)*{1,-1})/(COUNTIF(D$2:D$1000,J2)-1),"One Order")
 
Last edited:
Upvote 0
Sorry, I wasn't paying attention to your table. F2 could really be any blank cell.....so lets say you get a list of all customer IDs (if you don't have one already you could use Advanced filter on column D and get a unique list) and put that list in a blank column, e.g. column J, so if your list of IDs starts at J2 you could adjust the formula I suggested to this in K2:

=SUM(AGGREGATE({14,15},6,A$2:A$1000/(D$2:D$1000=J2),1)*{1,-1})/(COUNTIF(D$2:D$1000,J2)-1)

copy down and that should give you the average number of days between orders for each customer. If any customer has only 1 order then the above formula will give #DIV/0! error because there is no valid average in that case. If you want you can use IFERROR function to return another value, e.g.

=IFERROR(SUM(AGGREGATE({14,15},6,A$2:A$1000/(D$2:D$1000=J2),1)*{1,-1})/(COUNTIF(D$2:D$1000,J2)-1),"One Order")

Thanks Barry, the formula worked perfectly! Just one extra question - so if i'd just want to calculate the average only for customers with more than 2 orders, how do i modify the formula? Thanks again, you've been a great help.
 
Upvote 0
If you only want to average for customers with 3 or more orders then change to this version

=IF(COUNTIF(D$2:D$1000,J2)>=3,SUM(AGGREGATE({14,15},6,A$2:A$1000/(D$2:D$1000=J2),1)*{1,-1})/(COUNTIF(D$2:D$1000,J2)-1),"Fewer than 3 orders")
 
Upvote 0
Sorry to necro this thread, but just wanted to understand more. In the formula

=SUM(AGGREGATE({14,15},6,A$2:A$1000/(D$2:D$1000=J2),1)*{1,-1})/(COUNTIF(D$2:D$1000,J2)-1)

What is the use of *{1,-1}?
 
Upvote 0
It multiplies the max date by 1 & the min date by -1
 
Upvote 0

Forum statistics

Threads
1,216,028
Messages
6,128,383
Members
449,445
Latest member
JJFabEngineering

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top