Results 1 to 7 of 7

Count unique records for a specific date

Threaded View

  1. #4
    Forum Expert Ron Coderre's Avatar
    Join Date
    03-22-2005
    Location
    Boston, Massachusetts
    MS-Off Ver
    2013, 2016, O365
    Posts
    6,996

    Re: Count unique records for a specific date

    There are actually quite a few moving parts in this formula:
    F1: =SUMPRODUCT(--ISNUMBER(1/((MATCH(B2:B20&$E$1,B2:B20&A2:A20,0)-1+ROW(A$2))=ROW(B2:B20))))

    Basically, it looks for each first instance of Job#/Date combination
    where the date matches the referenced date.

    This section:
    MATCH(B2:B20&$E$1,B2:B20&A2:A20,0) finds the matches.

    and

    this section:
    -1+ROW(A$2)

    just tweaks the results of the match section so it returns row numbers.

    The first part: B2:B20&$E$1
    combines each actual Job# with the reference date
    in E1 (01-FEB-2010, in the example).
    Note: the Excel date serial number for that date is 40210.

    These are the Job#/Ref_Date pairs to find:
    List_1
    1040210
    1040210
    1040210
    1140210
    1240210
    1240210
    1340210
    1440210
    etc

    These are the actual pairs of Job# and Date
    from the Col_A/Col_B list:
    List_2
    1040210
    1040210
    1040210
    1140210
    1240211
    1240211
    1340211
    1440211

    so, the MATCH function looks for each List_1 item in List_2
    and returns the list position.

    In the example, the first 3 List_1 items (1040210) are found in the
    first position of List_2...but, only the first instance matches
    the row number, resulting in TRUE (which is converted to 1).

    All non-first-matches result in FALSE (which is converted to 0)

    Since those results are used in fraction denominators,
    1/1 is a valid number
    1/0 is an error (#DIV/0!)

    The ISNUMBER function, When applied to the list of returned values (errors or 1's),
    returns a 1 for each first instance and a 0 for each non-first-instance.

    The SUMPRODUCT function adds up the first-instance values to return their count.

    Perhaps not the clearest explanation, but that is definitely an advanced,
    NOT a beginner, formula.

    I hope that helps.
    Last edited by Ron Coderre; 02-22-2010 at 08:36 AM.

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