ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   COUNT and SUM with multiple criteria (https://www.excelbanter.com/excel-discussion-misc-queries/184251-count-sum-multiple-criteria.html)

KiltedPhotography

COUNT and SUM with multiple criteria
 
Two seperate functions I'm having problems creating.

First, I need a COUNT of the number of cells meeting TWO sets of criteria.
For example, "column A=final" AND "column B=14".

Seperately, I also need a sum of values in "column C" for the same
conditions above.



JLatham

COUNT and SUM with multiple criteria
 
To get a count of the NUMBER OF ROWS that have both "final" in column A AND
14 in column B:
=SUMPRODUCT(--(A1:A4="final"),--(B1:B4=14))

To get a total of the values in rows in column C where the above AND
condition is met:
=SUMPRODUCT(--(A1:A4="final"),--(B1:B4=14),C1:C4)

Those formulas assume data in rows 1 through 4, change the first
(1)/last(4) values to match the rows in use on your worksheet. Example: your
data goes from row 2 through row 29, the second formula would become:
=SUMPRODUCT(--(A2:A29="final"),--(B2:B29=14),C2:C29)



"KiltedPhotography" wrote:

Two seperate functions I'm having problems creating.

First, I need a COUNT of the number of cells meeting TWO sets of criteria.
For example, "column A=final" AND "column B=14".

Seperately, I also need a sum of values in "column C" for the same
conditions above.



Dave Peterson

COUNT and SUM with multiple criteria
 
If you're using xl2007, look at =countifs().

In any version...

=sumproduct(--(a1:a99="final"),--(b1:b99=14))

Adjust the ranges to match--but you can't use whole columns (except in xl2007).

=sumproduct() likes to work with numbers. The -- stuff changes trues and falses
to 1's and 0's.

Bob Phillips explains =sumproduct() in much more detail he
http://www.xldynamic.com/source/xld.SUMPRODUCT.html

And J.E. McGimpsey has some notes at:
http://mcgimpsey.com/excel/formulae/doubleneg.html



KiltedPhotography wrote:

Two seperate functions I'm having problems creating.

First, I need a COUNT of the number of cells meeting TWO sets of criteria.
For example, "column A=final" AND "column B=14".

Seperately, I also need a sum of values in "column C" for the same
conditions above.


--

Dave Peterson


All times are GMT +1. The time now is 06:20 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com