want sumif function's range to evaluate 2 columns

G

Guest

I wanted sumif to evaluate a range of cells over 2 columns.
My formula looked like this
=SUMIF(Q4:R27,">0",H4:H27)
Oddly enough, it works if there is a value >0 in column Q,
or in both columns Q and R,
but will not work if there is a value >0 in column R but no value >0 in
column Q.

How can I make it work? (And if anyone has time, why doesn't it work the
way it is now?)

Thanks,
Deb
 
B

Bob Phillips

=SUMIF(Q4:Q27,">0",H4:H27)+SUMIF(R4:R27,">0",H4:H27)

will work

--

HTH

RP
(remove nothere from the email address if mailing direct)
 
D

Domenic

Assuming that you want to sum the values in Column H where the
corresponding values in Column Q or Column R are greater than zero,
try...

=SUMPRODUCT(--((Q4:Q27>0)+(R4:R27>0)>0),H4:H27)

Hope this helps!
 
R

RagDyeR

From just looking at your formula, I could guess that you want *both*
Columns Q & R to be greater then zero before adding the value in Column H.

However, I did say *guess*.

Could it also be Q *OR* R greater then zero?

So, is it Q *AND* R
Or is it Q *OR* R ?

And which way should Sumif() translate it?

Q *and* R
=SUMPRODUCT((Q4:Q27>0)*(R4:R27>0)*H4:H27)

Q *or* R
=SUMPRODUCT(((Q4:Q27>0)+(R4:R27>0)>0)*H4:H27)
--

HTH,

RD
=====================================================
Please keep all correspondence within the Group, so all may benefit!
=====================================================

I wanted sumif to evaluate a range of cells over 2 columns.
My formula looked like this
=SUMIF(Q4:R27,">0",H4:H27)
Oddly enough, it works if there is a value >0 in column Q,
or in both columns Q and R,
but will not work if there is a value >0 in column R but no value >0 in
column Q.

How can I make it work? (And if anyone has time, why doesn't it work the
way it is now?)

Thanks,
Deb
 
G

Guest

Thanks Bob - it works like a charm.

Bob Phillips said:
=SUMIF(Q4:Q27,">0",H4:H27)+SUMIF(R4:R27,">0",H4:H27)

will work

--

HTH

RP
(remove nothere from the email address if mailing direct)
 
B

Bob Phillips

Really?

Mine and Domenic's can't both work like a charm, as they will return
different results. Mine is an AND condition, Domenic's is an OR. If say Q4
and R4 are >0, mine will add H4 twice, Domenic's just once.

--

HTH

RP
(remove nothere from the email address if mailing direct)
 
G

Guest

Hi,

It seems you want to sum the range if any one of columns (Q or R) have a 0.
You may also try the following array formula (Ctrl+Shift+Enter)

=sum(if((Q4:Q27>0)+(R4:R27>0),H4:H27))

Regards,

Ashish Mathur
 

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