+ Reply to Thread
Results 1 to 6 of 6

Count Unique Values in column A when meeting 2 criteria.

  1. #1
    Registered User
    Join Date
    02-02-2012
    Location
    London, England
    MS-Off Ver
    Excel 2010
    Posts
    10

    Count Unique Values in column A when meeting 2 criteria.

    Hello,

    Apologies, but our servers don't allow uploads/downloads to/from this site. I hope my explanation will suffice!

    I have a table of data and a separate summary table in which I want to return a value from the following.

    I my data table, in column A are client names, in column B are months expressed as a number and in column C are years.

    I am trying to return a count of unique values in column A:A when meeting a specific month (B:B) and a specific year (C:C). There can be multiple instances where one client name can appear within a specific month & year.

    The summary table has a row referencing months and a cell to reference the year. I cannot have an exhaustive list of client names to reference as the number can increase or decrease at any time.

    Thus far i have been trying various types of FREQUENCY formulae, coupled with COUNTIFS and IF statements, but I only ever manage to get a count, not a count of UNIQUE names.

    I hope someone can help! Thanks in advance!

  2. #2
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Count Unique Values in column A when meeting 2 criteria.

    Assuming your database is in a sheet named Data... create a dynamic named range that will allow for expansion/contraction of the data without having to reference entire columns....

    So while in the Data sheet, go to Formulas tab and select Define Name from Defined Names section, enter a name like MyData and use formula for refers to field:

    Please Login or Register  to view this content.
    and click Ok.

    Then in the main sheet enter a formula like:

    Please Login or Register  to view this content.
    confirmed with CTRL+SHIFT+ENTER not just ENTER.

    Note: Replace the 3 and 2012, respectively with cell references to month number and year, then re-confirm with CSE keys
    Where there is a will there are many ways.

    If you are happy with the results, please add to the contributor's reputation by clicking the reputation icon (star icon) below left corner

    Please also mark the thread as Solved once it is solved. Check the FAQ's to see how.

  3. #3
    Registered User
    Join Date
    02-02-2012
    Location
    London, England
    MS-Off Ver
    Excel 2010
    Posts
    10

    Re: Count Unique Values in column A when meeting 2 criteria.

    Thank so much. Unfortunately it's returning zero for every month. I have made sure to confirm with CSE but still no joy.

    Please see the adapted versions below that refer to the actual sheet I am working on, not the simplified example I gave in my explanation earlier.

    Data Table:

    MyData Range: ='Data Table'!$C$2:INDEX('Data Table'!$U:$U,MATCH(REPT("z",255),'Data Table'!$C:$C))

    Column C: Client Names
    Column S: Month
    Column U: Year


    [U]Summary Table:[\U]

    Formula: {=COUNT(1/FREQUENCY(IF(INDEX(MyData,0,19)=D$8,IF(INDEX(MyData,0,21)=$D$6,IF(INDEX(MyData,0,3)<>"",MATCH(INDEX(MyData,0,3),INDEX(MyData,0,3),0)))),ROW(INDEX(MyData,0,3))-MIN(ROW(INDEX(MyData,0,3)))+1))}

    Cell D6: Year
    Cell D8: Month


    Please note that for the INDEX functions i have tried referencing the column number by both the normal A=1, B=2 etc AND in relation to the MyData range (ie C=1, D=2 etc..)

    Thanks so much for your help!

  4. #4
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Count Unique Values in column A when meeting 2 criteria.

    Is D8 entered as a number or is it a date formatted as "MMM"?

    also, should it be:

    Please Login or Register  to view this content.
    since your named range starts at column C.. then column C is column # 1.... count from there on.

  5. #5
    Registered User
    Join Date
    02-02-2012
    Location
    London, England
    MS-Off Ver
    Excel 2010
    Posts
    10

    Re: Count Unique Values in column A when meeting 2 criteria.

    You are a legend.

    This is perfect and now I can make applications to other criteria too!

    Can't thank you enough!

    Brilliant!

  6. #6
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Count Unique Values in column A when meeting 2 criteria.

    You are welcome.

    Please mark your thread as Solved.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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