+ Reply to Thread
Results 1 to 5 of 5

Counting with multiple criteria

  1. #1
    Valued Forum Contributor scaffdog845's Avatar
    Join Date
    02-01-2008
    Location
    Aston, PA. USA.
    MS-Off Ver
    Microsoft 365
    Posts
    373

    Counting with multiple criteria

    Morning all,

    I have common tasks where I need to sort through large amounts of data to receive a total number of line entries matching multiple criteria in different columns. I've attached a Workbook with a simplified example. On STATS!B1 I would like to total, from DATA!, all lines which have "1A" in A:A and any of the following in E:E (RP, SAO, AE, RSNR).

    As always, help from the group is appreciated.
    Attached Files Attached Files
    Last edited by scaffdog845; 10-07-2009 at 11:53 AM. Reason: Solved

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

    Re: Counting with multiple criteria

    Try:

    =SUMPRODUCT((DATA!A:A="1A")*(DATA!E:E={"RP","SAO","AE","RSNR"}))

    although faster if you used defined ranges... and if you have just "1A" in A1 so that formula can reference the cell instead of hard-coding "1A" into it.
    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
    Valued Forum Contributor scaffdog845's Avatar
    Join Date
    02-01-2008
    Location
    Aston, PA. USA.
    MS-Off Ver
    Microsoft 365
    Posts
    373

    Re: Counting with multiple criteria

    I see what you mean. The formula worked relatively well in the small example file, however when I tried it in the working workbook (containing 2632 records) and added the additional criteria (8 more match types) Excel ran out of available resources. I broke it down into chunks and added them together which seemed to help, but it still took a few seconds. The final formula looked like this =SUMPRODUCT(('Planning Data'!A:A="1A")*('Planning Data'!E:E={"PAA","RS"}))+SUMPRODUCT(('Planning Data'!A:A="1A")*('Planning Data'!E:E={"RSNR","S"}))+SUMPRODUCT(('Planning Data'!A:A="1A")*('Planning Data'!E:E={"SAM","SAMT"}))+SUMPRODUCT(('Planning Data'!A:A="1A")*('Planning Data'!E:E={"SAO","SAT"}))+SUMPRODUCT(('Planning Data'!A:A="1A")*('Planning Data'!E:E={"SOR","WKS"}))

    My profile may be old and still reflecting MS Excel 2003. I have since upgraded to MS Excel 2007 if that helps with any new formulae.

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

    Re: Counting with multiple criteria

    Does converting the range to a defined range improve it?

    e.g=SUMPRODUCT((DATA!A$1:A$2600="1A")*(DATA!E$1:E$2600={"RP","SAO","AE","RSNR"}))

  5. #5
    Valued Forum Contributor scaffdog845's Avatar
    Join Date
    02-01-2008
    Location
    Aston, PA. USA.
    MS-Off Ver
    Microsoft 365
    Posts
    373

    Re: Counting with multiple criteria

    Works great with a defined range. I wasn't even thinking about the millions of cells the formula had to parse in '07. I cut it down to 3 times the expected range to be safe and bingo.

    THANKS!

+ 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