+ Reply to Thread
Results 1 to 8 of 8

Retention formula to count unique customers that made a purchase in both years

  1. #1
    Registered User
    Join Date
    10-19-2015
    Location
    Sydney, Australia
    MS-Off Ver
    2013
    Posts
    10

    Retention formula to count unique customers that made a purchase in both years

    Hi,

    I've been searching google and this forum for several days, but haven't found a solution to count unique customers that purchased something in both years (ie. a retention formula), so I was wondering if someone here had a solution. So my data is a table of purchase records that very simply looks like this -

    A B C D
    Customer ID Year Purchased
    56474 2015
    114931 2015
    39934 2015
    63819 2015
    114931 2016
    39934 2016
    47010 2016


    So what I need is, if I put the criteria '2015' in cell D1, and '2016' in cell D2, then in D4 a calculation will count how many unique customers bought something in both 2015 & 2016 (which will be '2' ie. only customer IDs 114931 & 39934 both bought something in 2015 & 2016.)

    My data has almost 200,000 rows with around 10,000 different customers, so if someone had a UDF, I'd be ecstatic since that will run faster, but an array formula will suffice.

    Thanks in advance for your consideration.

  2. #2
    Forum Guru Kaper's Avatar
    Join Date
    12-14-2013
    Location
    Warsaw, Poland
    MS-Off Ver
    most often: Office 365 in Windows environment
    Posts
    8,623

    Re: Retention formula to count unique customers that made a purchase in both years

    This shall do reasonably quick:
    in worksheet (of course your range):
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    in standard module UDF:
    Please Login or Register  to view this content.
    Best Regards,

    Kaper

  3. #3
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,829

    Re: Retention formula to count unique customers that made a purchase in both years

    I'm not really sure if a UDF will be faster than an array formula. From what little I see said about them, the fastest approach to this kind of "summarization" is often a pivot table. I set it up with years as row labels, ID# as column labels. The number of 2's in the Grand Total row will indicate how many unique customers were present in both years. If you filter out either year, then you can get the ID# for each year. If you expand the source data, you should be able to figure out the logic to determine how many unique ID#'s are present for whatever years you choose to pivot. I would expect that something built on a pivot table will be faster than a formula or VBA approach.
    Attached Files Attached Files
    Quote Originally Posted by shg
    Mathematics is the native language of the natural world. Just trying to become literate.

  4. #4
    Registered User
    Join Date
    10-19-2015
    Location
    Sydney, Australia
    MS-Off Ver
    2013
    Posts
    10

    Re: Retention formula to count unique customers that made a purchase in both years

    MrShorty, I was aware I could do something manual in a minute using a pivot table, then filtering and expanding things, particularly using the Distinct Count row summation if I use 'Add to the Data Model' option. Since this is such a common analysis question "What is the retention rate of our customers year on year" I was wondering if Excel had something automated by now, where it could show the figures year on year without having to filter anything. Let me know if you discover such a functionality using a pivot table.

    Kaper, your UDF works like a treat - thank you very much (greetings to Warsaw from Sydney)! I have the data as a Table named "Customer_Purchases", and the 'Customer ID' column and 'Year' column are named respectively in the table. Is it possible for the UDF to reference the table name and these column names, or alternatively how do I rewrite your code if the Customer ID is in column G and the Year is in column Q?

    Thanks again.

  5. #5
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 v 2403
    Posts
    13,406

    Re: Retention formula to count unique customers that made a purchase in both years

    This appears to be a one-off formula you want.

    In E4 array-entered:

    =SUM(IF(FREQUENCY(IF(TRANSPOSE($D$1:$D$2)=$B$2:$B$8,$A$2:$A$8),$A$2:$A$8)>1,1))



    A
    B
    C
    D
    1
    Cust ID#
    Year Purchased
    2015
    2
    56474
    2015
    2016
    3
    114931
    2015
    4
    39934
    2015
    2
    5
    63819
    2015
    6
    114931
    2016
    7
    39934
    2016
    8
    47010
    2016
    Dave

  6. #6
    Forum Guru Kaper's Avatar
    Join Date
    12-14-2013
    Location
    Warsaw, Poland
    MS-Off Ver
    most often: Office 365 in Windows environment
    Posts
    8,623

    Re: Retention formula to count unique customers that made a purchase in both years

    In this form not but just slight modification (error checking shall probably be added) but as you plan to use it with tables:
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    at least basic requirement that ranges are the same length will be fulfilled automatically.
    The changed code:

    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    10-19-2015
    Location
    Sydney, Australia
    MS-Off Ver
    2013
    Posts
    10

    Re: Retention formula to count unique customers that made a purchase in both years

    FlameRetired, thanks for taking the time to reply. I'll store that formula away.

    Kaper, that UDF is exactly what I've been looking for. I've modified it below to accommodate criteria that are strings and not just integers.

    Please Login or Register  to view this content.
    Thanks again for your help.

  8. #8
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 v 2403
    Posts
    13,406

    Re: Retention formula to count unique customers that made a purchase in both years

    You're welcome. Thanks for the feedback.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Count of Age group with unique customers
    By Rushendra in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 03-23-2016, 01:21 AM
  2. count for unique customers
    By stephme55 in forum Excel General
    Replies: 9
    Last Post: 01-30-2016, 06:27 PM
  3. [SOLVED] New customers count formula
    By makinmomb in forum Excel Formulas & Functions
    Replies: 14
    Last Post: 12-14-2014, 03:44 PM
  4. Determine repeat customers vs. new customers based on purchase date
    By mktgdude in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 05-02-2013, 04:10 AM
  5. Macro Reqd to update Purchase order log, everytime a new purchase order is made
    By manthankanabar in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 10-23-2012, 01:47 AM
  6. Replies: 2
    Last Post: 06-04-2012, 01:02 AM
  7. I wish to count changes to a cell made by a formula
    By kebabman in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 10-13-2010, 10:12 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1