ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Sumproduct using and, and or (https://www.excelbanter.com/excel-discussion-misc-queries/151666-sumproduct-using.html)

Lori

Sumproduct using and, and or
 
I'm trying to add the numbers in column C, based on multiple conditions in
column A (or statement) and conditions in column B (an and statement to
column A). In the example below, I want to add the values in Column C based
on Column A equaling either X or Z, and Column B equaling NA (result would be
7)

A B C
X NA 2
X IDDD 1
Y NA 3
Y IDDD 2
Z NA 5
Z IDDD 4


Pete_UK

Sumproduct using and, and or
 
Try this:

=SUMPRODUCT((A1:A10="X")*(B1:B10="NA")*(C1:C10)) +
SUMPRODUCT((A1:A10="Z")*(B1:B10="NA")*(C1:C10))

Or, you might want to try:

=SUMPRODUCT(((A1:A10="X") + (A1:A10="Z"))*(B1:B10="NA")*(C1:C10))

which is a bit shorter.

Hope this helps.

Pete

On Jul 25, 5:00 pm, Lori wrote:
I'm trying to add the numbers in column C, based on multiple conditions in
column A (or statement) and conditions in column B (an and statement to
column A). In the example below, I want to add the values in Column C based
on Column A equaling either X or Z, and Column B equaling NA (result would be
7)

A B C
X NA 2
X IDDD 1
Y NA 3
Y IDDD 2
Z NA 5
Z IDDD 4




Toppers

Sumproduct using and, and or
 
=SUMPRODUCT((A2:A7={"X","Z"})*(B2:B7="NA")*(C2:C7) )

"Pete_UK" wrote:

Try this:

=SUMPRODUCT((A1:A10="X")*(B1:B10="NA")*(C1:C10)) +
SUMPRODUCT((A1:A10="Z")*(B1:B10="NA")*(C1:C10))

Or, you might want to try:

=SUMPRODUCT(((A1:A10="X") + (A1:A10="Z"))*(B1:B10="NA")*(C1:C10))

which is a bit shorter.

Hope this helps.

Pete

On Jul 25, 5:00 pm, Lori wrote:
I'm trying to add the numbers in column C, based on multiple conditions in
column A (or statement) and conditions in column B (an and statement to
column A). In the example below, I want to add the values in Column C based
on Column A equaling either X or Z, and Column B equaling NA (result would be
7)

A B C
X NA 2
X IDDD 1
Y NA 3
Y IDDD 2
Z NA 5
Z IDDD 4






All times are GMT +1. The time now is 07:05 PM.

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