Consulting

Results 1 to 3 of 3

Thread: Solved: SUM(IF with an OR statement produces incorrect results.

  1. #1
    VBAX Mentor
    Joined
    Jan 2009
    Posts
    304
    Location

    Solved: SUM(IF with an OR statement produces incorrect results.

    I have a large data sheet and want to count the “unique records” using the following formula:

    {=SUM(IF(FREQUENCY(IF('data dump'!$A$2:$A$2000="Commit",IF(OR('data dump'!$B$2:$B$2000="Chicago",'data dump'!$B$2:$B$2000="Minnesota"),IF('data dump'!$D$2:$D$2000<>"",MATCH('data dump'!$D$2:$D$2000,'data dump'!$D$2:$D$2000,0)))),ROW('data dump'!$D$2:$D$2000)-ROW($D$2)+1),1))}

    The formula works if I remove the OR part (OR('data dump'!$B$2:$B$2000="Chicago",). I need to test for 2 different values in B2:B2000.

    I tried to use a Sumproduct formula but couldn’t make it work either.

    Any ideas why this formula does not work?

    Thanks...

    JimS

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Try this

    =SUM(IF(FREQUENCY(IF('data dump'!$A$2:$A$20="Commit",IF(('data dump'!$B$2:$B$20="Chicago")+('data dump'!$B$2:$B$20="Minnesota"),
    IF('data dump'!$D$2:$D$20<>"",MATCH('data dump'!$D$2:$D$20,'data dump'!$D$2:$D$20,0)))),ROW('data dump'!$D$2:$D$20)-ROW($D$2)+1),1))
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  3. #3
    VBAX Mentor
    Joined
    Jan 2009
    Posts
    304
    Location
    Perfect, Thanks...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •