Thread: sumif with or
View Single Post
  #10   Report Post  
Alok
 
Posts: n/a
Default

Hi
This is happening because both functions are returning an array. The first
function returns a single element in the array. The second function returns a
two element array. If there is no function that operates on the array of
values returned then Excel tends to use the first value of the array.
If you enclose your Sumif within a Sum function like Aladin had done you
will see that there is a difference. The second function will then return a
number which is interpreted as the Sum of all numbers where D5:D12 is less
than 900 plus some of all numbers where the range D5:D12 is greater than 100.
This is different than the sum of all numbers where D5:D12 is greater than
100 or less than 900 (which is basically all numbers.) In other words the
method shown by Aladin has to be used cautiously - that is only in case of
non-overlapping ranges. In other words this is probably OK

=SUM(SUMIF(D5:D12, {"<100","900"},G5:G12))

if one intends to find the Sum of all numbers in G5 to G12 where the numbers
in D5:D12 are either smaller than 100 or greater than 900.

Alok




"C Glenn" wrote:

I can't get this to work. In every case, the first criteria is applied
and the second is ignored.

Put these numbers in D, starting at D5:

45
123
789
4156
123
456
987
321


Now put these in G, starting at G5:

65
32
8546
123
646
564
6
54

If you put the following in G13:
=SUMIF(D5:D12, {"<900","100"},G5:G12)
it will return the same result as
=SUMIF(D5:D12, {"<900"},G5:G12).

The result of the first formula should be 65 less than the second.






Alok wrote:
Glenn,
This does work but you have to enclose them in quotes. {"<100","250"}
Alok

"C Glenn" wrote:


Somewhat like an implicit OR but it's actually an implicity IN! I'm
wondering if there are any other possibilities, i.e.: <250, 125. This
doesn't work with the curlies.

Thanks.

Aladin Akyurek wrote:

=SUM(SUMIF(B5:B12,{"D*","?D*"},D5:D12))

C Glenn wrote:


I'm trying to do this:

=SUMIF(B5:B12,OR("=D*","=?D*"),D5:D12)

It returns zero each time.

(BTW,
=SUMIF(B5:B12,"=D*",D5:D12)
and
=SUMIF(B5:B12,"=?D*",D5:D12)
both work just fine and return non zero sums.)

So my question is,
Where do I put the OR, or is there another way to do this?