SUMIF with two columns

J

Joseph N.

[Excel 2003] Assume a worksheet with with numbers in column A; Boolean
criterion [Y or N] in column B; and another Boolean criterion [Y or N]
in column C. I would like to add the numbers in column A for all rows
that have 'y' in both columns B and C.

I have been trying to do this with a SUMIF statement in which the
criteria is a combination of the two columns. I have not been able to
find the magic formula, so either I am missing the correct syntax or
there is a better formula to use.

Help would be appreciated!
 
B

Bernard Liengme

The double negation in terms two and three are there to convert True and
FALSE to 1 and 0, repespectivley
So we do not need them in the first term
=SUMPRODUCT(A1:A25,--(B1:B25="Y"),--(C1:C25="Y"))
For more details on SUMPRODUCT
http://www.xldynamic.com/source/xld.SUMPRODUCT.html
http://mcgimpsey.com/excel/formulae/doubleneg.html
best wishes
--
Bernard V Liengme
Microsoft Excel MVP
www.stfx.ca/people/bliengme
remove caps from email

Alan said:
=SUMPRODUCT(--(A1:A25),--(B1:B25="Y"),--(C1:C25="Y"))
Regards,
Alan.
Joseph N. said:
[Excel 2003] Assume a worksheet with with numbers in column A; Boolean
criterion [Y or N] in column B; and another Boolean criterion [Y or N]
in column C. I would like to add the numbers in column A for all rows
that have 'y' in both columns B and C.

I have been trying to do this with a SUMIF statement in which the
criteria is a combination of the two columns. I have not been able to
find the magic formula, so either I am missing the correct syntax or
there is a better formula to use.

Help would be appreciated!
 
R

Ron Rosenfeld

[Excel 2003] Assume a worksheet with with numbers in column A; Boolean
criterion [Y or N] in column B; and another Boolean criterion [Y or N]
in column C. I would like to add the numbers in column A for all rows
that have 'y' in both columns B and C.

I have been trying to do this with a SUMIF statement in which the
criteria is a combination of the two columns. I have not been able to
find the magic formula, so either I am missing the correct syntax or
there is a better formula to use.

Help would be appreciated!


=SUMPRODUCT(A1:A1000*(B1:B1000="Y")*(C1:C1000="Y"))
--ron
 
E

Ed Hansberry, MS-MVP/Mobile Devices

Joseph N. said:
[Excel 2003] Assume a worksheet with with numbers in column A; Boolean
criterion [Y or N] in column B; and another Boolean criterion [Y or N]
in column C. I would like to add the numbers in column A for all rows
that have 'y' in both columns B and C.

I have been trying to do this with a SUMIF statement in which the
criteria is a combination of the two columns. I have not been able to
find the magic formula, so either I am missing the correct syntax or
there is a better formula to use.

Help would be appreciated!

As others have suggested, creative use of the sumproduct()
formula can do it. FWIW, Excel 2007 introduced a new function
called sumifs() that handles it natively.

More on using sumproduct() for this purpose -
http://www.xldynamic.com/source/xld.SUMPRODUCT.html
--
__________________________________________________________________________________
Ed Hansberry (Please do *NOT* email me. Post here for the benefit of all)
What is on my Pocket PC? http://www.ehansberry.com/
Microsoft MVP - Mobile Devices www.pocketpc.com
What is an MVP? -
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top