+ Reply to Thread
Results 1 to 11 of 11

Counting Unique Occurences in excel?

  1. #1
    Registered User
    Join Date
    05-13-2008
    Posts
    5

    Counting Unique Occurences in excel?

    Does anyone here know how to count unique Occurneces in Excel?

    For example: -

    What formula can I use to count the Unique Occurences non - zero values in Column 2 for the letters in Column 1?

    Column 1 Column 2
    A 1
    A 1
    A 1
    B 0
    C 2
    C 2
    D -1

  2. #2
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229
    What results do you want from the sample data posted?

    Do you want the duplicated A 1 's to be counted as one or as none?
    _
    ...How to Cross-post politely...
    ..Wrap code by selecting the code and clicking the # or read this. Thank you.

  3. #3
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,526
    Quote Originally Posted by ayo
    Does anyone here know how to count unique Occurneces in Excel?

    For example: -

    What formula can I use to count the Unique Occurences non - zero values in Column 2 for the letters in Column 1?

    Column 1 Column 2
    A 1
    A 1
    A 1
    B 0
    C 2
    C 2
    D -1
    This kind of formula could work for you
    =SUMPRODUCT((A1:A7="A")*(B1:B7<>0))

    more on sumproduct
    http://www.xldynamic.com/source/xld.SUMPRODUCT.html

  4. #4
    Forum Expert
    Join Date
    06-18-2004
    Location
    Canada
    MS-Off Ver
    Office 2016
    Posts
    1,474
    To count the unique items in the first column, where the corresponding value in the second column is a non-zero value, assuming that A2:B8 contains the data, try...

    =SUM(IF(FREQUENCY(IF($A$2:$A$8<>"",IF($B$2:$B$8<>0,MATCH("~"&$A$2:$A$8,$A$2:$A$8&"",0))),ROW($A$2:$A$8)-ROW($A$2)+1)>0,1))

    ...confirmed with CONTROL+SHIFT+ENTER.

    Hope this helps!

  5. #5
    Registered User
    Join Date
    05-13-2008
    Posts
    5

    reply

    I want duplicate values in the first column to be counted as one. Becos they would correspond to the same non zero value in the second column.\

    So A is counted as one since it corresponds to the same non zero value. D is also counted as one since it corresponds to -1, the same for C 2. The formula is going to be used for a larger set.

    Thanks - Ayo

    A 1
    A 1
    A 1
    B 0
    C 2
    C 2
    D -1
    Last edited by ayo; 05-14-2008 at 11:43 AM.

  6. #6
    Forum Expert
    Join Date
    06-18-2004
    Location
    Canada
    MS-Off Ver
    Office 2016
    Posts
    1,474
    Post deleted...
    Last edited by Domenic; 05-14-2008 at 12:02 PM. Reason: Added comment...

  7. #7
    Registered User
    Join Date
    05-13-2008
    Posts
    5

    reply

    A 1
    A 1
    A 1
    B 0
    C 2
    C 2
    D -1


    Count = 3 ; B is the only field that matches zero

    - Ayo

  8. #8
    Forum Expert
    Join Date
    06-18-2004
    Location
    Canada
    MS-Off Ver
    Office 2016
    Posts
    1,474
    The formula I offered should return the desired result. Have you tried it?

  9. #9
    Registered User
    Join Date
    05-13-2008
    Posts
    5

    reply

    Domenic,

    using this: -

    =SUM(IF(FREQUENCY(IF($C$3:$C$47164<>"",IF($M$3:$M$47164<>0,MATCH("~"&$C$3:$C$47164,$C$3:$C$47164&"",0))),ROW($C$3:$C$47164)-ROW($C$3)+1)>0,1))


    I keep getting this when I past it in a field - #VALUE!

    Please Advise
    Last edited by ayo; 05-14-2008 at 12:24 PM.

  10. #10
    Forum Expert
    Join Date
    06-18-2004
    Location
    Canada
    MS-Off Ver
    Office 2016
    Posts
    1,474
    The formula needs to be confirmed with CONTROL+SHIFT+ENTER, not just ENTER. If done correctly, Excel will automatically place curly brackets {....} around the formula. If you've pasted the formula into a cell, click in the formula bar and then confirm with CONTROL+SHIFT+ENTER.
    Last edited by Domenic; 05-14-2008 at 12:30 PM.

  11. #11
    Registered User
    Join Date
    05-13-2008
    Posts
    5

    Reply

    thanks Domenic

    I've confirmed it and it works.

    - Ayo

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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