• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Average time between multiple dates (tied with a unique identifier)

Shareit

New Member
Hi,I have a database with 100,000(+) unique customer ID tied to their invoice dates (of purchasing)over a period of 3 years. I would like to understand the buying pattern of each customer by calculating the average time between their purchases (determined by their invoice dates. Sample as below:


Transaction Data:


ID Invoice Date (mm/yyyy)

AA 01/2013

AA 01/2013

BB 07/2011

BB 01/2011

BB 07/2010

BB 07/2010

BB 06/2010

BB 05/2010

BB 05/2010

BB 03/2010

CC 02/2010

CC 01/2010

CC 04/2010

CC 09/2012

CC 01/2013

DD 12/2012

EE 11/2012

EE 06/2012

EE 05/2012

FF 03/2012

FF 01/2013

… …

… …


Is there a straight forward formula where I can feed the "average time between invoice dates" into the table below (using the left column (ID) as a table of reference)?


Analysis:


ID Average Time between Invoice Dates (in days)

AA:

BB:

CC:

DD:

EE:

FF


 
Yes.. park it outside.. and provide us the KEY to check your vehicle..


http://chandoo.org/forums/topic/posting-a-sample-workbook


Regards,

Deb
 
Hi ,


Suppose we assume that your unique IDs are listed in a range K2:K8 as follows :

[pre]
Code:
AA_15841170
AA_15637893
AA_15638848
AA_15638855
AA_15638856
AA_15638860
AA_15639108
[/pre]
In L2 , enter the following formula , as an array formula , using CTRL SHIFT ENTER :


=(MAX(IF($B$2:$B$22=K2,$C$2:$C$22))-MIN(IF($B$2:$B$22=K2,$C$2:$C$22,99999999)))/COUNTIF($B$2:$B$22,K2)


I have assumed that your data is in columns B and C , from B2:C22.


Narayan
 
Hi Narayank991, thanks, but the results don't look right (with negatives).

Just wondering why is there a '9999999' within the formula?
 
Hi ,


I went with your original sample data ; now that you have uploaded your workbook , I'll check it out , and see.


Narayan
 
Hi ,


Try this :


=(MAX(IF($A$3:$A$66=D3,$B$3:$B$66))-MIN(IF($A$3:$A$66=D3,$B$3:$B$66,99999999)))/COUNTIF($A$3:$A$66,D3)


Narayan
 
Thanks Narayan,

The above formula looks 'logically right', but somehow did not elicit the right results.

And when drag it down the column, the results got even more bizarre. Any idea if we could rectify the formula ?
 
Hi, sorry for this late response, as I have been away.


If you could refer to this link below: (https://docs.google.com/spreadsheet/ccc?key=0AlWgMhjadVZ4dFJYSWVCTDAwMEJHSzJLT0tWWEM2Vnc&usp=sharing)


Then you'll know what I mean.

The results doesnt look like its in days/weeks. Kindly advise.


Thanks!
 
Back
Top