sumproduct or countif

F

freebee

Hi, I need to sum numbers in one column based on 2 critarias from another
column, I have formula as
=SUMPRODUCT(--($O$20:$O$79="a"),--($O$20:$O$79="b"),$Q$20:$Q$79)
but the result showed 0.
Am I correct for using sumproduct or shall I use countif (which I haven't
learned yet)?
Thank you.
 
T

T. Valko

So, the criteria is: O20:O79 = A *OR* B

Try one of these:

=SUMPRODUCT((O20:O79={"a","b"})*Q20:Q79)

=SUM(SUMIF(O20:O79,{"a","b"},Q20:Q79))
 
J

JMay

=SUMPRODUCT(--(A1:A10="a")+--(A1:A10="b"),B1:B10)

change column letters row numbers according to your set up..
 
T

T. Valko

The first one did not work

You must have some entries other than numbers in the sum range if it didn't
work.
 
S

ShaneDevenshire

Hi,

A totally different idea - suppose there are titles on row 19, directly
above the data, and suppose the one in O19 is "Letter". In a separate range
enter
Letter
a
b

Suppose this is in D1:D3
The you can use the formula

=DSUM(O19:Q79,3,D1:D3)

The D-functions are under employed because they require a criteria range
somewhere else in the spreadsheet. But they do produce simple easy to
understand formulas regardless of how complex the criterial.
 
D

David Biddulph

You don't need the double unary minus if you've got the addition. The
arithmetic operation is enough to coerce the conversion from boolean to
number. Double unary minus (or double unary negation if you prefer) is just
a way of forcing an arithmetic operation where you don't already have one.
You'll see that if you use the SUMPRODUCT((condition1)*(condition2)) format
you don't need the double unary minus, but with
SUMPRODUCT(--(condition1),--(condition2)) [comma instead of multiply] you do
need it.
 

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