ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   Sumproduct Multiple < Conditions (https://www.excelbanter.com/excel-worksheet-functions/134912-sumproduct-multiple-conditions.html)

undrline via OfficeKB.com

Sumproduct Multiple < Conditions
 
So, normally I would use this format for my conditional formulas:

=SUMPRODUCT(--((X2:X500="foo")+(X2:X500="oof")0),--(Y2:Y500<100),(Z2:Z500))

Which gets me the sum of column Z, if column Y is less than 100, and column X
is "foo" OR "oof"

I'm keep hitting a problem, though, with one type of conditional . . . what
if I want every thing that is NEITHER "foo" NOR "oof" ?

=SUMPRODUCT(--((X2:X500<"foo")+(X2:X500<"oof")0),--(Y2:Y500<100),(Z2:Z500))


is wrong . . . because it's telling it NOT "foo" OR NOT "oof" . . .

thank you for any help.

--
Message posted via http://www.officekb.com


Dave Peterson

Sumproduct Multiple < Conditions
 
How about:

=SUMPRODUCT(--(X2:X500<"foo"),--(X2:X500<"oof"),--(Y2:Y500<100),(Z2:Z500))

And I'd be careful with your original formula. I think you're missing a pair of
()'s.

=SUMPRODUCT(--((X2:X500="foo")+(X2:X500="oof")0),--(Y2:Y500<100),(Z2:Z500))
should be:
=SUMPRODUCT(--(((X2:X500="foo")+(X2:X500="oof"))0),--(Y2:Y500<100),(Z2:Z500))

(foo+oof)0, right?


"undrline via OfficeKB.com" wrote:

So, normally I would use this format for my conditional formulas:

=SUMPRODUCT(--((X2:X500="foo")+(X2:X500="oof")0),--(Y2:Y500<100),(Z2:Z500))

Which gets me the sum of column Z, if column Y is less than 100, and column X
is "foo" OR "oof"

I'm keep hitting a problem, though, with one type of conditional . . . what
if I want every thing that is NEITHER "foo" NOR "oof" ?

=SUMPRODUCT(--((X2:X500<"foo")+(X2:X500<"oof")0),--(Y2:Y500<100),(Z2:Z500))

is wrong . . . because it's telling it NOT "foo" OR NOT "oof" . . .

thank you for any help.

--
Message posted via http://www.officekb.com


--

Dave Peterson

Teethless mama

Sumproduct Multiple < Conditions
 
Try this:

=SUMPRODUCT((X2:X500<"foo")*(X2:X500<"oof")*(Y2: Y500<100)*(Z2:Z500))


"undrline via OfficeKB.com" wrote:

So, normally I would use this format for my conditional formulas:

=SUMPRODUCT(--((X2:X500="foo")+(X2:X500="oof")0),--(Y2:Y500<100),(Z2:Z500))

Which gets me the sum of column Z, if column Y is less than 100, and column X
is "foo" OR "oof"

I'm keep hitting a problem, though, with one type of conditional . . . what
if I want every thing that is NEITHER "foo" NOR "oof" ?

=SUMPRODUCT(--((X2:X500<"foo")+(X2:X500<"oof")0),--(Y2:Y500<100),(Z2:Z500))


is wrong . . . because it's telling it NOT "foo" OR NOT "oof" . . .

thank you for any help.

--
Message posted via http://www.officekb.com



undrline via OfficeKB.com

Sumproduct Multiple < Conditions
 
Hmm, normally pointing to two conditions in the same column is bad . . . but
maybe the < changes it . . . I think I found a different solution, though.

About the 0 . . . it's what I was told to do in this thread:
http://www.officekb.com/Uwe/Forum.as...tes-like-Sumif


Here's why the 0 doesn't make sense to me, and the formula seems to always
work without it at all:
My understanding is that an array is turned into a set of ones-and-zeros,
representing true or false, which are then multiplied against the
corresponding rows in the other arrays . . . if any zeros appear, then the
whole thing is zero, and only if every array is one, for that same row, will
they stay one. If one was not a conditional array with a "--" then one
multiplied by that number is that number. Then, the new (resulting) array is
totalled, either giving a count if all were conditional arrays, or a sum, if
it had that one non-conditional. So, in order to have two options from one
column, it might confuse the function as to what row it's testing in the
arrays: so the thought is that one cell would not hold two separate values.
It would be one or the other. Therefore, one of the multiple conditions
("foo" or "oof") has to be false for that cell, or zero. So, the sum of the
two conditions should be 0+1, 0+0, or 1+0. I don't see any way that you
would ever have a negative number. Maybe empty cells? But empty cells are
an empty string value in Excel by default, and would still evaluate to true
or false. Of the three options, there is one that would throws a fit when
you wrap parenthesis around the whole thing . . . (0+0)0 . . . you're
evaluating falsefalse, and it doesn't want to evaluate to false. Every time
I've tried it, it doesn't seem to work.


Dave Peterson wrote:
How about:

=SUMPRODUCT(--(X2:X500<"foo"),--(X2:X500<"oof"),--(Y2:Y500<100),(Z2:Z500))

And I'd be careful with your original formula. I think you're missing a pair of
()'s.

=SUMPRODUCT(--((X2:X500="foo")+(X2:X500="oof")0),--(Y2:Y500<100),(Z2:Z500))
should be:
=SUMPRODUCT(--(((X2:X500="foo")+(X2:X500="oof"))0),--(Y2:Y500<100),(Z2:Z500))

(foo+oof)0, right?

So, normally I would use this format for my conditional formulas:

[quoted text clipped - 14 lines]
--
Message posted via http://www.officekb.com



--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...tions/200703/1


undrline via OfficeKB.com

Sumproduct Multiple < Conditions
 
I really prefer the double unary operator, mostly because it makes it easier
to read, and discern conditions from sums. But using * as AND, and + as OR
makes sense:

I think this would work:
=SUMPRODUCT(--((X2:X500<"foo")*(X2:X500<"oof")),--(Y2:Y500<100),(Z2:Z500))

Thanks.

Thank you both for helping out.




Teethless mama wrote:
Try this:

=SUMPRODUCT((X2:X500<"foo")*(X2:X500<"oof")*(Y2 :Y500<100)*(Z2:Z500))

So, normally I would use this format for my conditional formulas:

[quoted text clipped - 11 lines]

thank you for any help.


--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...tions/200703/1



All times are GMT +1. The time now is 11:16 PM.

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