+ Reply to Thread
Results 1 to 11 of 11

Count unique occurences in column A if column B equals value

  1. #1
    Registered User
    Join Date
    07-24-2014
    Location
    Plano, Texas
    MS-Off Ver
    2013
    Posts
    19

    Angry Count unique occurences in column A if column B equals value

    Hello, I am trying to figure out how to count the unique occurrences in column A based on the value in column B. In the example below, I am trying to count the number of unique names in each state (Illinois=1, Colorado=2, New York=2). I would like the formula to count unique occurrences for the entire column A because I will be adding to the list. I feel like it should be somewhat simple, but it is driving me crazy. Any help would be appreciated


    ..A.............B............C
    John......Illinois
    John.....Illinois
    John.....Colorado
    Alex.....Colorado
    Alex.....New York
    Steve...New York
    Steve...New York

  2. #2
    Valued Forum Contributor
    Join Date
    07-07-2014
    Location
    Washington DC
    MS-Off Ver
    2007
    Posts
    1,047

    Re: Count unique occurences in column A if column B equals value

    You can use the Remove Duplicates function. That will tell you how many duplicates were removed and the number of remaining unique entries.

  3. #3
    Registered User
    Join Date
    07-24-2014
    Location
    Plano, Texas
    MS-Off Ver
    2013
    Posts
    19

    Re: Count unique occurences in column A if column B equals value

    Unfortunately the data that spreadsheet is on is going to be provided each week and each is a separate case. I need to write a formula, without VBA, that will count the unique occurrences if column B is a certain value.


    I have tried SUM(IF(FREQUENCY())) which I believe is the right way to go, but I cant figure out how to structure it

  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: Count unique occurences in column A if column B equals value

    Like this...

    Data Range
    A
    B
    C
    D
    E
    1
    Name
    State
    State
    Count
    2
    John
    Illinois
    Illinois
    1
    3
    John
    Illinois
    Colorado
    2
    4
    John
    Colorado
    New York
    2
    5
    Alex
    Colorado
    6
    Alex
    New York
    7
    Steve
    New York
    8
    Steve
    New York
    9
    ------
    ------
    ------
    ------
    ------


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

    =SUM(IF(FREQUENCY(IF(B$2:B$8=D2,MATCH(A$2:A$8,A$2:A$8,0)),ROW(B$2:B$8)-ROW(B$2)+1),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.

    I would like the formula to count unique occurrences for the entire column A because I will be adding to the list.
    You should avoid using entire columns in array formulas.

    Instead, create and use some dynamic ranges.

    Tell me EXACTLY where this data is located and I'll help you create the dynamic ranges.
    Biff
    Microsoft MVP Excel
    Keep It Simple Stupid

    Let's Go Pens. We Want The Cup.

  5. #5
    Registered User
    Join Date
    07-24-2014
    Location
    Plano, Texas
    MS-Off Ver
    2013
    Posts
    19

    Re: Count unique occurences in column A if column B equals value

    Okay, I'm really sorry I feel like that should work but I cant seem to make it work. I have uploaded a snapshot of the table. I tried to simplify my example by changing the context so maybe that is part of the issue.

    I am trying to count unique occurrences of column A (SA/A 1, SA/A 2, SA/A 3 and SA/A 4) for each region (AMS, APJ, EMEA and USPS). So AMS=1, APJ=2, EMEA=1 and USPS=1...

    If you could give it a shot I would REALLY appreciate it
    Attached Files Attached Files

  6. #6
    Registered User
    Join Date
    07-24-2014
    Location
    Plano, Texas
    MS-Off Ver
    2013
    Posts
    19

    Re: Count unique occurences in column A if column B equals value

    Here is my attempt - please note, I am trying to reference the whole column because the list will be added to.

    Let me know if you see where I am going wrong...
    Attached Files Attached Files

  7. #7
    Forum Expert
    Join Date
    03-28-2014
    Location
    Hyderabad,India
    MS-Off Ver
    Excel 2013
    Posts
    1,887

    Re: Count unique occurences in column A if column B equals value

    I am dam sure what is happening in this formula, i have just correct the range D to d16
    The value is 1 which is expected as per you .check with any other typical
    use ctrl+Shift+Enter
    =SUM(IF(FREQUENCY(IF(DATA!D$2:$D$16=A2,MATCH(DATA!A$2:$A$16,DATA!A$2:$A$16,0)),ROW(DATA!D$2:$D$16)-ROW(DATA!$D$2:$D$16)+1),1))
    Punnam

  8. #8
    Registered User
    Join Date
    07-24-2014
    Location
    Plano, Texas
    MS-Off Ver
    2013
    Posts
    19

    Re: Count unique occurences in column A if column B equals value

    Thank you, that is working for me but is it possible to use $D$2:$D and $A$2:$A in order to reference the whole column besides the column label/title?

    I am getting an error when, but the list is going to be constantly added to by multiple people so I don't want to have to constantly update the formula

  9. #9
    Forum Expert
    Join Date
    03-28-2014
    Location
    Hyderabad,India
    MS-Off Ver
    Excel 2013
    Posts
    1,887

    Re: Count unique occurences in column A if column B equals value

    hi,

    Have checked the correctness of the formula by adding any additional data fields ?
    First do the check,

    i have updated range as u asked o do if for entire column.

    Punnam
    Attached Files Attached Files

  10. #10
    Registered User
    Join Date
    07-24-2014
    Location
    Plano, Texas
    MS-Off Ver
    2013
    Posts
    19

    Re: Count unique occurences in column A if column B equals value

    Yeah, for some reason on the version you just uploaded the calculation for APJ=1 but it should be 2 (SA/A 2 and SA/A 3 in cells A8 and A9 ...do you know how to fix that?

    Also, here is my latest attempt. It works correctly for AMS but I get #VALUE for the other 3 regions
    Attached Files Attached Files

  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 occurences in column A if column B equals value

    Try this...

    Create these defined names.

    Goto the Formulas tab>Define name

    Name: Solution
    Refers to: =DATA!$A$2:INDEX(DATA!$A:$A,MATCH("zzzzz",DATA!$A:$A))

    Name: Region
    Refers to: =DATA!$D$2:INDEX(DATA!$D:$D,MATCH("zzzzz",DATA!$D:$D))

    OK out

    Then, on the formula sheet enter this array formula** in B2:

    =SUM(IF(FREQUENCY(IF(Region=A2,MATCH(Solution,Solution,0)),ROW(Solution)-MIN(ROW(Solution))+1),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.

    Copy down as needed.

    Here's your file with this implemented:
    Attached Files Attached Files

+ 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 UNIQUE OCCURENCES IF - in column A based on value of column B
    By butler1012 in forum Hello..Introduce yourself
    Replies: 3
    Last Post: 07-26-2014, 07:59 AM
  2. [SOLVED] Count unique occurences in one column with unique occurances in another column
    By 21stCenturyLessons in forum Excel General
    Replies: 5
    Last Post: 07-12-2014, 08:44 AM
  3. [SOLVED] Need to count if Column A contains definded text and Column B equals defined word
    By JBlo in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 03-26-2014, 01:38 PM
  4. Replies: 2
    Last Post: 03-06-2012, 03:40 AM
  5. [SOLVED] How do I count the # of unique occurences of a text in a column?
    By Rob Kaiser in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 10-14-2005, 02:05 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