+ Reply to Thread
Results 1 to 12 of 12

Count unique data in Column, but exclude if certain data is in another Column

  1. #1
    Registered User
    Join Date
    03-25-2014
    Location
    United States
    MS-Off Ver
    Excel 2003
    Posts
    17

    Count unique data in Column, but exclude if certain data is in another Column

    I have a list of names in column B with some repeating. I use the following formula to count how many unique names are in the column.

    =ArrayFormula(SUM(IFERROR(1/COUNTIF(B5:B,B5:B),0)))

    I now want to reference data in column C, which are numbers, and only count the unique names in Column B if the correlating number in Column C is greater than 0.


    Your help is appreciated.

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

    Re: Count unique data in Column, but exclude if certain data is in another Column

    Is =ArrayFormula a UDF?

  3. #3
    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 data in Column, but exclude if certain data is in another Column

    Post some sample data and tell us what result you expect.
    Biff
    Microsoft MVP Excel
    Keep It Simple Stupid

    Let's Go Pens. We Want The Cup.

  4. #4
    Registered User
    Join Date
    03-25-2014
    Location
    United States
    MS-Off Ver
    Excel 2003
    Posts
    17

    Re: Count unique data in Column, but exclude if certain data is in another Column

    Here is a sample workbook:Book.xlsx

  5. #5
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: Count unique data in Column, but exclude if certain data is in another Column

    =ArrayFormula(SUM(IFERROR(1/COUNTIF(B5:B,B5:B),0))) is google sheets syntax
    "Unless otherwise stated all my comments are directed at OP"

    Mojito connoisseur and now happily retired
    where does code go ?
    look here
    how to insert code

    how to enter array formula

    why use -- in sumproduct
    recommended reading
    wiki Mojito

    how to say no convincingly

    most important thing you need
    Martin Wilson: SPV
    and RSMBC

  6. #6
    Forum Expert Vikas_Gautam's Avatar
    Join Date
    06-04-2013
    Location
    Ludhiana,Punjab, India
    MS-Off Ver
    Excel 2013
    Posts
    1,850

    Re: Count unique data in Column, but exclude if certain data is in another Column

    here is the solution..
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    Edit:- Tony's solution is more efficient... should go with that..

    check the attached file..
    Attached Files Attached Files
    Last edited by Vikas_Gautam; 12-11-2014 at 02:10 AM.
    Regards,
    Vikas Gautam
    Excel-buzz.blogspot.com

    Excel is not a matter of Experience, its a matter of Application.

    Say Thanks, Click * Add Reputation

  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 data in Column, but exclude if certain data is in another Column

    The note in the file says:

    Count Unique Cities in Column B but exclude if Column C is more then 0 (this exmple would be 7)
    However, I don't see how it's possible to arrive at that result.

    Did you mean:

    Count Unique Cities in Column B where column C is more than 0 (this exmple would be 7)

    If that's the case try this array formula**:

    =SUM(IF(FREQUENCY(IF(C2:C19>0,MATCH(B2:B19,B2:B19,0)),ROW(B2:B19)-ROW(B2)+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.

  8. #8
    Registered User
    Join Date
    03-25-2014
    Location
    United States
    MS-Off Ver
    Excel 2003
    Posts
    17

    Re: Count unique data in Column, but exclude if certain data is in another Column

    Apologies, that's what I meant.

    Thank you Tony Valko & Vikas Gautam, they both worked! Exactly what I needed!

  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 data in Column, but exclude if certain data is in another Column

    You're welcome. We appreciate the feedback!

  10. #10
    Registered User
    Join Date
    03-25-2014
    Location
    United States
    MS-Off Ver
    Excel 2003
    Posts
    17

    Re: Count unique data in Column, but exclude if certain data is in another Column

    1 Step further... What if I added another column to this?

    So "Count Unique Cities in Column B where Column C and/or Column D are more than 0"

  11. #11
    Forum Expert Vikas_Gautam's Avatar
    Join Date
    06-04-2013
    Location
    Ludhiana,Punjab, India
    MS-Off Ver
    Excel 2013
    Posts
    1,850

    Re: Count unique data in Column, but exclude if certain data is in another Column

    The revised formula would be:-
    for AND Condition:
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    For OR Condition:
    Formula: copy to clipboard
    Please Login or Register  to view this content.

  12. #12
    Registered User
    Join Date
    03-25-2014
    Location
    United States
    MS-Off Ver
    Excel 2003
    Posts
    17

    Re: Count unique data in Column, but exclude if certain data is in another Column

    Thank you!

+ 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] How do I exclude data from 1 column using conditions from another column
    By Funky Gibbon in forum Excel Formulas & Functions
    Replies: 18
    Last Post: 12-15-2013, 06:44 PM
  2. Count adjacent column of unique data
    By stevenoob in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 07-16-2013, 10:27 PM
  3. Replies: 2
    Last Post: 03-06-2012, 03:40 AM
  4. Replies: 4
    Last Post: 06-30-2011, 04:11 PM
  5. Replies: 8
    Last Post: 02-16-2011, 05:03 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