+ Reply to Thread
Results 1 to 9 of 9

count unique values of 2 columns with criteria

Hybrid View

  1. #1
    Registered User
    Join Date
    11-19-2012
    Location
    Chennai
    MS-Off Ver
    Excel 2007
    Posts
    5

    count unique values of 2 columns with criteria

    Hello,
    The following is my data:
    A B C D
    Red Good .... 1
    Blue Bad .... 3
    Red Bad .... 1
    Orange Good .... 9
    Green Worse .... 2
    Blue Good .... 4
    Yellow Worse .... 4
    White Good .... 1
    Blue Good .... 4
    Green Good .... 2
    Red Good .... 2

    Requirement: Using a formula, I need to count for each colour in Column-A with the criteria "Good" in Column-B, the number of unique values in Column-D. For e.g. for Red with criteria Good, total unique values in Column-D is 2.
    Ideally, I would like to copy the unique colours in another column(say E) and then count the unique values in D based on criteria in B and give the answer in a new column(say F) against each colour.
    How can I achieve this?

    Regards.
    Bala

  2. #2
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    53,048

    Re: count unique values of 2 columns with criteria

    please upload a sample workbook. when you copy/paste here, it often does not come out as intened

    To attach a file to your post,
    click advanced (next to quick post),
    scroll down until you see "manage file",
    click that and select "add files" (top right corner).
    click "select files" find your file, click "open" click "upload" click 'done" bottom right. click "submit reply"

    Once the upload is completed the file name will appear below the input boxes in this window.
    You can then close the window to return to the new post screen.
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  3. #3
    Registered User
    Join Date
    11-19-2012
    Location
    Chennai
    MS-Off Ver
    Excel 2007
    Posts
    5

    Re: count unique values of 2 columns with criteria

    Hello,
    I have attached the sample file. In this, I need to find the following:
    Find the no.of unique testers who did the Product Test & Product Validation(Colum1) for the "OK" testcases(Column4).

    Regards,
    Bala
    Attached Files Attached Files

  4. #4
    Forum Expert Fotis1991's Avatar
    Join Date
    10-11-2011
    Location
    Athens(The homeland of the Democracy!). Greece
    MS-Off Ver
    Excel 1997!&2003 & 2007&2010
    Posts
    13,744

    Re: count unique values of 2 columns with criteria

    In E1 and copy down.

    =IF(AND(OR(D2="OK");OR(A2="ProductTest";A2="ProductValidation"));1;"")

    In G2 and copy down.

    =IFERROR(INDEX($B$2:$B$31;SMALL(IF(ISNA(MATCH($B$2:$B$31;$G$1:G1;0));IF($E$2:$E$31=1;ROW($B$2:$B$31)-ROW($B$2)+1));1));"")
    Attached Files Attached Files
    Regards

    Fotis.

    -This is my Greek whisper to Europe.

    --Remember, saying thanks only takes a second or two. Click the little star * below, to give some Rep if you think an answer deserves it.

    Advanced Excel Techniques: http://excelxor.com/

    --KISS(Keep it simple Stupid)

    --Bring them back.

    ---See about Acropolis of Athens.

    --Visit Greece.

  5. #5
    Registered User
    Join Date
    11-19-2012
    Location
    Chennai
    MS-Off Ver
    Excel 2007
    Posts
    5

    Re: count unique values of 2 columns with criteria

    Hi Fotis,
    Thanks for the solution. But I have some difficulties. The no.of rows running to 10,000 and so it is difficult to copy down. Is there a formula to count the unique values(with text) with multiple criteria?

    Bala

  6. #6
    Forum Guru (RIP) Marcol's Avatar
    Join Date
    12-23-2009
    Location
    Fife, Scotland
    MS-Off Ver
    Excel '97 & 2003/7
    Posts
    7,216

    Re: count unique values of 2 columns with criteria

    Quote Originally Posted by kbalasub View Post
    Hi Fotis,
    ... Is there a formula to count the unique values(with text) with multiple criteria?

    Bala
    Try using Dynamic Names, this workbook uses Fotis' idea, but for 2003, you can use IFERROR() in the formula
    Formula: copy to clipboard
    =IFERROR(INDEX(Tester,SMALL(IF(ISNA(MATCH(Tester,$F$1:F1,0)),IF(Helper=1,ROW(Tester)-ROW($B$2)+1)),1))),"")

    Either way these are CSE arrays, and must be confirmed with Ctrl+Shift+Enter not just Enter.

    Hopefully this should work for any length your data table might be.

    Does this work for you?

    [EDIT]
    Server to busy ... try again later
    More crashes causing errors!
    When are the "Tech Wizards" going to stop f***ing about, this has been going on for weeks now.
    Can they really be this incontinent, sorry, incompetent? ...
    Attached Files Attached Files
    Last edited by Marcol; 02-15-2013 at 08:13 AM. Reason: Wrong Attachment, due to Forum upload problem, now corrected
    If you need any more information, please feel free to ask.

    However,If this takes care of your needs, please select Thread Tools from menu above and set this topic to SOLVED. It helps everybody! ....

    Also
    اس کی مدد کرتا ہے اگر
    شکریہ کہنے کے لئے سٹار کلک کریں
    If you are satisfied by any members response to your problem please consider using the small Star icon bottom left of their post to show your appreciation.

  7. #7
    Forum Expert Fotis1991's Avatar
    Join Date
    10-11-2011
    Location
    Athens(The homeland of the Democracy!). Greece
    MS-Off Ver
    Excel 1997!&2003 & 2007&2010
    Posts
    13,744

    Re: count unique values of 2 columns with criteria

    Took me less than a minute to drag down the formulae! So for me wasn't difficult at all!

  8. #8
    Registered User
    Join Date
    11-19-2012
    Location
    Chennai
    MS-Off Ver
    Excel 2007
    Posts
    5

    Re: count unique values of 2 columns with criteria

    Thanks for your immediate response. The file I uploaded was only a sample. My actual file has more 10,000 rows and it is not easy to drag or copy for 10,000 rows. Also, this requirement has to be implemented repeatedly for multiple projects. So the best would be a formula which can calculate unique text values with multiple criteria.

  9. #9
    Forum Guru (RIP) Marcol's Avatar
    Join Date
    12-23-2009
    Location
    Fife, Scotland
    MS-Off Ver
    Excel '97 & 2003/7
    Posts
    7,216

    Re: count unique values of 2 columns with criteria

    That's what the attachment in post #7 does, is it not? ...

+ 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