+ Reply to Thread
Results 1 to 16 of 16

Count unique entries based off unique criteria in another column

  1. #1
    Forum Contributor
    Join Date
    10-26-2011
    Location
    Ottawa, ON Canada
    MS-Off Ver
    Excel 2011 for Mac
    Posts
    128

    Count unique entries based off unique criteria in another column

    Workbook2.xlsx

    See attached sample. What I'd like to do is count how many times 'Bob' is listed with unique dates. So in the sample, Bob would be '4', as he's listed again May 20, 21, 22, and 23,and 'John' would be '3' as his name is listed against May 20,21,22.

    If I could get something that would create a list of all unique entries in column 2, with the 'count' result next to that?

    Hopefully this is explained ok?!

    Thanks for your help.

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

    Re: Count unique entries based off unique criteria in another column

    Try this...

    Data Range
    A
    B
    C
    D
    E
    1
    20-May
    BOB
    Bob
    3
    2
    20-May
    BOB
    John
    4
    3
    20-May
    BOB
    ------
    ------
    ------
    4
    20-May
    BOB
    5
    20-May
    BOB
    6
    20-May
    BOB
    7
    20-May
    BOB
    8
    20-May
    BOB
    9
    20-May
    BOB
    10
    20-May
    BOB


    This array formula** entered in E1 and copied down:

    =SUM(IF(FREQUENCY(IF(B$1:B$91=D1,A$1:A$91),A$1:A$91),1))

    ** array formulas need to be entered using the key
    combination of CTRL,SHIFT,ENTER (not just ENTER).
    Hold down both the CTRL key and the SHIFT key
    then hit ENTER.
    Biff
    Microsoft MVP Excel
    Keep It Simple Stupid

    Let's Go Pens. We Want The Cup.

  3. #3
    Forum Expert
    Join Date
    05-30-2012
    Location
    The Netherlands
    MS-Off Ver
    Office 365
    Posts
    14,987

    Re: Count unique entries based off unique criteria in another column

    c1=
    Please Login or Register  to view this content.
    d1
    Please Login or Register  to view this content.
    and drag down.

    The values that represent 1 are the unique values.

    Eventualy you can filter them.

    See the attached file.
    Attached Files Attached Files
    Notice my main language is not English.

    I appreciate it, if you reply on my solution.

    If you are satisfied with the solution, please mark the question solved.

    You can add reputation by clicking on the star * add reputation.

  4. #4
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Count unique entries based off unique criteria in another column

    Hi,

    In C1
    =B1&A1
    In D1
    =IF(MAX(1,COUNTIF($C$1:$C1,$C1))>1,0,1)
    both copied down. Then apply a pivot table to A1:Dnn and put column D in the PT along with the names and dates.
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  5. #5
    Forum Guru sktneer's Avatar
    Join Date
    04-30-2011
    Location
    Kanpur, India
    MS-Off Ver
    Office 365
    Posts
    9,648

    Re: Count unique entries based off unique criteria in another column

    Or try this Regular Formula (not array formula)

    In E1
    Please Login or Register  to view this content.
    Attached Files Attached Files
    Regards
    sktneer


    Treat people the way you want to be treated. Talk to people the way you want to be talked to.
    Respect is earned NOT given.

  6. #6
    Registered User
    Join Date
    05-16-2014
    MS-Off Ver
    Excel 2003
    Posts
    44

    Re: Count unique entries based off unique criteria in another column

    @ Tony .How does the frequency part work here? Just trying to understand. Thanks

    Avi

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

    Re: Count unique entries based off unique criteria in another column

    FREQUENCY returns a series of "count if" results.

    In this case it's a conditional count if based on the corresponding name.

    Consider this example:

    Data Range
    A
    B
    C
    D
    E
    1
    5/20/2014
    Sue
    Tom
    2
    2
    5/20/2014
    Tom
    3
    5/20/2014
    Tom
    4
    5/21/2014
    Tom
    5
    5/21/2014
    Bob
    6
    ------
    ------
    ------
    ------
    ------


    We want to count the unique dates that correspond to Tom.

    The dates that correspond to Tom are:

    5/20/2014
    5/20/2014
    5/21/2014

    FREQUENCY performs a seires of "count ifs" on the dates that fall into the date bins:

    A1: 5/20/2014
    A2: 5/20/2014
    A3: 5/20/2014
    A4: 5/21/2014
    A5: 5/21/2014

    Only the unique bins generate a count.

    The "count ifs" would be:

    Count If 5/20/2014 is less than or equal to 5/20/2014 = 2
    Count If 5/20/2014 = already counted = 0
    Count If 5/20/2014 = already counted = 0
    Count If 5/21/2014 is greater than 5/20/2014 and less than or equal to 5/21/2014 = 1
    Count If 5/21/2014 = already counted = 0
    Count If any dates are greater than 5/21/2014 = 0

    So the FREQUENCY function returns this array:

    {2;0;0;1;0;0}

    From that array we want to count how many elements are greater than 0.

    So, the count of unique dates that correspond to Tom = 2.

    I'm pretty sure this is confusing but if you read it a few times it might make sense!

  8. #8
    Registered User
    Join Date
    05-16-2014
    MS-Off Ver
    Excel 2003
    Posts
    44

    Re: Count unique entries based off unique criteria in another column

    Thank you so much. I Almost broke down your formula and understood through evaluate formula and got about 80% of it. Now its more clear. Thanks for detailed explanation.

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

    Re: Count unique entries based off unique criteria in another column

    You're welcome. Thanks for the feedback!

  10. #10
    Registered User
    Join Date
    05-16-2014
    MS-Off Ver
    Excel 2003
    Posts
    44

    Re: Count unique entries based off unique criteria in another column

    Sorry Just one more Question. In your formula frequency has something like

    Frequency({false,false,41780},$A1:A$91) and i believe frequency evaluates to zero there for false? Am i correct

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

    Re: Count unique entries based off unique criteria in another column

    The Boolean FALSE is ignored.

  12. #12
    Registered User
    Join Date
    05-16-2014
    MS-Off Ver
    Excel 2003
    Posts
    44

    Re: Count unique entries based off unique criteria in another column

    Thanks a ton for patience.

  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: Count unique entries based off unique criteria in another column

    You're welcome!

  14. #14
    Forum Contributor
    Join Date
    10-26-2011
    Location
    Ottawa, ON Canada
    MS-Off Ver
    Excel 2011 for Mac
    Posts
    128

    Re: Count unique entries based off unique criteria in another column

    Amazing... Thanks for all the replies! I ended up using Richard's method, which was fairly fast.

    In C1
    =B1&A1
    In D1
    =IF(MAX(1,COUNTIF($C$1:$C1,$C1))>1,0,1)
    both copied down. Then apply a pivot table to A1:Dnn and put column D in the PT along with the names and dates.

    All seemed to do the trick in one form or another.

    Sktneer - Thanks for this one - Probably would have been the easiest solution.
    =SUMPRODUCT(--(FREQUENCY(INDEX((B$1:B$91=D1)*A$1:A$91,0),A$1:A$91)>0))

  15. #15
    Forum Guru sktneer's Avatar
    Join Date
    04-30-2011
    Location
    Kanpur, India
    MS-Off Ver
    Office 365
    Posts
    9,648

    Re: Count unique entries based off unique criteria in another column

    You're welcome. Thanks for the feedback and rep.

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

    Re: Count unique entries based off unique criteria in another column

    Quote Originally Posted by hambly View Post
    Thanks for this one - Probably would have been the easiest solution.
    =SUMPRODUCT(--(FREQUENCY(INDEX((B$1:B$91=D1)*A$1:A$91,0),A$1:A$91)>0))
    The SUM(IF array version is more efficient (faster to calculate).

+ 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. [SOLVED] Count unique entries across columns based on criteria
    By flomme in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 08-15-2013, 06:43 PM
  2. Count unique occurrances based off criteria in a different column
    By Enovy in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 03-05-2013, 03:28 PM
  3. [SOLVED] Count Unique Pairs of Excel Entries Based on Criteria
    By DonFord81 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 01-22-2013, 01:12 PM
  4. Count unique entries in one column where a criteria is met in another column
    By DonutMonster in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 03-14-2012, 06:49 PM
  5. count unique entries with criteria
    By shinbar in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 05-03-2005, 02:31 PM

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