A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Excel » Worksheet Functions
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

sumif with or



 
 
Thread Tools Display Modes
  #21  
Old October 17th, 2005, 11:55 PM
C Glenn
external usenet poster
 
Posts: n/a
Default sumif with or

Thanks Aladin. This is very helpful.

Chris.

Aladin Akyurek wrote:
1.

=SUM(COUNTIF(B5:B12,{"D*", "A*"}))

And: With E2 housing the D condition and F2 the A condition...

2.

=SUMPRODUCT(COUNTIF(B5:B12,E2:F2&"*"))

3.

=SUMPRODUCT(--ISNUMBER(MATCH(LEFT(B5:B12),E2:F2,0)))

C Glenn wrote:

Hey, one more question in this regard. Suppose I wanted to count the
number of cells in the same rows as those that match the specified
criteria (instead of adding them), could I do that? (I need to.)

I tried =COUNT(SUMPRODUCT(... but that returned 1.

I also tried =COUNTIF(... but I can't get it to respect more than one
criteria.
=COUNTIF(B5:B12, {"D*", "A*"})
returned the same result as
=COUNTIF(B5:B12, {"D*"})

Any ideas on this?


Aladin Akyurek wrote:

If you like to have conditions hard-coded into your formulas...

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

would constitute such an example. You are right about the constant
array acting as IN or as a chain of OR's.

Conditions like 250 and 125 that must kold at the same time cannot
be expressed with IN.

Some options a

[1]

=SUMIF(ConditionRange,""&125,SumRange)-SUMIF(ConditionRange,"="&250,SumRange)


[2]

=SUMPRODUCT(--(ConditionRange125),--(ConditionRange250),SumRange)

Since you are inquiring about whether a SumIf formula with an
array-constant which would work with 250 and 125...

If we look at how [1] is built, we can derive:

=SUM(SUMIF(ConditionRange,{"125","=250"),SumRang e)*{1,-1})

which could be useful in some circumstances. A variablized version
would be:

=SUMPRODUCT(SUMIF(ConditionRange,X2:Y2,SumRange)*{ 1,-1})

where X2 literally houses 125 and Y2 =250. Trying to variablize [2]
the same way would not allow specifying X2:Y2 in the foregoing manner.

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*"},D512))

C Glenn wrote:

I'm trying to do this:

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

It returns zero each time.

(BTW,
=SUMIF(B5:B12,"=D*",D512)
and
=SUMIF(B5:B12,"=?D*",D512)
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?





  #22  
Old October 17th, 2005, 11:56 PM
C Glenn
external usenet poster
 
Posts: n/a
Default sumif with or

Worked perfectly. Found I could get it to respect text comparisons as well.

Thanks, Chris.

Tom Ogilvy wrote:
in this formula
=SUMPRODUCT(--(ConditionRange125),--(ConditionRange250),SumRange)

leave of the argument SumRange and you will get the count

=SUMPRODUCT(--(ConditionRange125),--(ConditionRange250))

 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to use SUMIF to return sums between two values located in cells ScottBerger Worksheet Functions 1 November 18th, 2004 07:09 PM
SUMIF vs SUM(IF(..)) vs SUMPRODUCT Harlan Grove Worksheet Functions 7 July 1st, 2004 10:22 PM
SUMIF vs SUM(IF(..)) vs SUMPRODUCT Harlan Grove General Discussion 7 July 1st, 2004 10:22 PM
Multiple SUMIF functions ? Frank Kabel Worksheet Functions 0 February 26th, 2004 11:46 AM
Narrow range in Sumif formula Steve Worksheet Functions 2 January 14th, 2004 06:16 PM


All times are GMT +1. The time now is 06:41 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.