+ Reply to Thread
Results 1 to 3 of 3

Count Conditional Distinct Values

  1. #1
    Forum Contributor
    Join Date
    09-19-2004
    Location
    Canada
    Posts
    408

    Count Conditional Distinct Values

    Hi all,

    I am using the following array formula to count distinct values in column A where the first two characters is "12" and corresponding cell in another column E is not blank:

    PHP Code: 
    =SUM(IF((LEFT($A$2:$A$67,2)="12")*($E$2:$E$67<>""),1/COUNTIF($A$2:$A$67,$A$2:$A$67))) 
    But it is not giving the correct result - see attachment. It should be 63 instead of 62, but I can't figure out why.

    Any help, please?

    Thank you,
    Gos-C
    Attached Files Attached Files
    Last edited by Gos-C; 02-10-2013 at 05:42 AM.
    Using Excel 2010 & Windows 10
    "It is better to be prepared for an opportunity and not have one than to have an opportunity and not be prepared."

  2. #2
    Forum Expert
    Join Date
    07-16-2010
    Location
    Northumberland, UK
    MS-Off Ver
    Excel 2007 (home), Excel 2010 (work)
    Posts
    3,054

    Re: Count Conditional Distinct Values

    The COUNTIF you're dividing by isn't conditional on column E being empty, so the values on rows 7 and 66 are being counted as 1/2 each, rather than 1 each.

    You can fix this by using a COUNTIFS as the divisor:

    =SUM(IF((LEFT($A$2:$A$67,2)="12")*($E$2:$E$67<>""),1/COUNTIFS($A$2:$A$67,$A$2:$A$67,E2:E67,"<>")))

  3. #3
    Forum Contributor
    Join Date
    09-19-2004
    Location
    Canada
    Posts
    408

    Re: Count Conditional Distinct Values

    Oh! Great. Thank you very much, Andrew-R. Greatly appreciated.

    Cheers,
    Gos-C

+ 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