+ Reply to Thread
Results 1 to 13 of 13

Multiple Condition Countifs with Uniqueness as Condition

  1. #1
    Registered User
    Join Date
    02-08-2013
    Location
    Los Angeles
    MS-Off Ver
    Excel 2010
    Posts
    25

    Multiple Condition Countifs with Uniqueness as Condition

    Please see attached. This is a stripped-down excerpt of a data set with over 800k rows. I have tried EVERYTHING. All kinds of Countifs, Sumifs, Sumproducts, even some DCountas. I consider myself an intermediate to advanced user, and I can't figure this out at all. The main snag is calculating the original cohort: it needs to be only those users that transacted 2 or more times with "dog" BEFORE a certain date, and those users are only counted once regardless of the number of transactions (so if a user had 8 transactions of dog before the date, he still counts as one unique user). I'm at my wit's end, don't really know what to do from here. Any guidance much appreciated.
    Last edited by semantics; 02-19-2017 at 10:20 PM.

  2. #2
    Registered User
    Join Date
    02-08-2013
    Location
    Los Angeles
    MS-Off Ver
    Excel 2010
    Posts
    25

    Re: Impossibly difficult counting exercise

    For some reason I can't attach a file. Here's a link:

    https://www.dropbox.com/s/sed7iajd3w...mple.xlsb?dl=0

  3. #3
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,916

    Re: Impossibly difficult counting exercise

    Unfortunately the attachment icon doesn't work at the moment, so to attach an Excel file you have to do the following: just before posting, scroll down to Go Advanced and then scroll down to Manage Attachments. Now follow the instructions at the top of that screen.

    Many members can't or won't open files from file-sharing sites.
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  4. #4
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Impossibly difficult counting exercise

    Quote Originally Posted by semantics View Post
    This is a stripped-down excerpt of a data set with over 800k rows.
    Counting conditional uniques from 800k rows of data will be slow!
    Biff
    Microsoft MVP Excel
    Keep It Simple Stupid

    Let's Go Pens. We Want The Cup.

  5. #5
    Valued Forum Contributor kasan's Avatar
    Join Date
    07-22-2009
    Location
    Riga, Latvia
    MS-Off Ver
    Excel 2010
    Posts
    680

    Re: Impossibly difficult counting exercise

    Hi,
    Calculating with formulas can be really slow on 800k records.
    Faster way to manage it - using VBA array with Scripting Dictionary. Looping through array is much more faster that calculations on worksheet, and Dictionary can be useful to detect duplicate records.
    Please write back if it's OK to solve it with VBA (not formulas), then we could firure out some code.

  6. #6
    Registered User
    Join Date
    02-08-2013
    Location
    Los Angeles
    MS-Off Ver
    Excel 2010
    Posts
    25

    Re: Impossibly difficult counting exercise

    Quote Originally Posted by kasan View Post
    Hi,
    Calculating with formulas can be really slow on 800k records.
    Faster way to manage it - using VBA array with Scripting Dictionary. Looping through array is much more faster that calculations on worksheet, and Dictionary can be useful to detect duplicate records.
    Please write back if it's OK to solve it with VBA (not formulas), then we could firure out some code.
    Yes, that's okay. I can work with VBA, but this is a conceptually difficult problem for me.

  7. #7
    Valued Forum Contributor kasan's Avatar
    Join Date
    07-22-2009
    Location
    Riga, Latvia
    MS-Off Ver
    Excel 2010
    Posts
    680

    Re: Impossibly difficult counting exercise

    Ok, try this code. It should calculate count of users with 2 or more "dog" transactions before 08/31.
    Could you please describe more in detail what do we need to calculate next? For 09/30, 10/31 and so on?

    Please Login or Register  to view this content.

  8. #8
    Registered User
    Join Date
    02-08-2013
    Location
    Los Angeles
    MS-Off Ver
    Excel 2010
    Posts
    25

    Re: Impossibly difficult counting exercise

    double post

  9. #9
    Registered User
    Join Date
    02-08-2013
    Location
    Los Angeles
    MS-Off Ver
    Excel 2010
    Posts
    25

    Re: Impossibly difficult counting exercise

    Quote Originally Posted by kasan View Post
    Ok, try this code. It should calculate count of users with 2 or more "dog" transactions before 08/31.
    Could you please describe more in detail what do we need to calculate next? For 09/30, 10/31 and so on?

    Please Login or Register  to view this content.
    That worked beautifully. Thank you so much.

    The next step is to say, okay, of that 1320 people that purchased dog >= 2 times before 8/31:

    How many of those 1320 purchased dog >= 1 time in the last 60 days from 9/30? (i.e. from 8/1 to 9/30). How many from 9/30 purchased dog >= 1 time in the last 60 days from 10/31? (i.e. 9/1 to 10/31) Basically a moving 60 day window that ends on the next EOMONTH date. Keep doing that until the data ends on 1/31/17.

  10. #10
    Valued Forum Contributor kasan's Avatar
    Join Date
    07-22-2009
    Location
    Riga, Latvia
    MS-Off Ver
    Excel 2010
    Posts
    680

    Re: Impossibly difficult counting exercise

    Try out this code. It should calculate all figures you need.
    Before you run the code fill dates of first days of the month in row 6. G6 = 2016.08.01, H6 = 2016.09.01 and so on.

    Please Login or Register  to view this content.

  11. #11
    Registered User
    Join Date
    02-08-2013
    Location
    Los Angeles
    MS-Off Ver
    Excel 2010
    Posts
    25

    Re: Impossibly difficult counting exercise

    Quote Originally Posted by kasan View Post
    Try out this code. It should calculate all figures you need.
    Before you run the code fill dates of first days of the month in row 6. G6 = 2016.08.01, H6 = 2016.09.01 and so on.

    Please Login or Register  to view this content.
    I would hug you if I could. Thank you so much.

  12. #12
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    12,612

    Re: Impossibly difficult counting exercise

    title updated.
    Last edited by protonLeah; 02-21-2017 at 06:11 PM.
    Ben Van Johnson

  13. #13
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Impossibly difficult counting exercise

    The original thread title seems to have been satisfactory for a moderator as they replied to the thread without objection.

+ 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. Replies: 2
    Last Post: 12-20-2013, 12:12 AM
  2. Excel 2007 : Help with exercise !
    By juno28 in forum Excel General
    Replies: 3
    Last Post: 04-20-2012, 06:51 AM
  3. Counting unique customers filtered by date
    By perducci in forum Excel General
    Replies: 2
    Last Post: 03-08-2012, 12:49 PM
  4. Columbia student exercise, Monthly > Quarterly data by Macro exercise
    By alepenn in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-18-2011, 12:04 AM
  5. Difficult Excel exercise
    By sarisman in forum Excel General
    Replies: 6
    Last Post: 06-14-2008, 12:12 PM
  6. Need help with a exercise
    By han83 in forum Excel General
    Replies: 1
    Last Post: 04-02-2008, 08:03 AM

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