# Re: SUMIF with broken range

joeu2004
Guest
Posts: n/a

 18th Aug 2012
"Wesler" <(E-Mail Removed)> wrote:
> I am trying to get three different sums from the same range:
> 1) All positive numbers
> 2) All negative numbers
> 3) The total (which I can get fine)
> I tried this all kinds of ways, but the method below
> works for the negative numbers, but give me an obscenely
> high (and incorrect) number for the positive numbers:
> Any ideas?

Not sure how "broken" your ranges are. Post your SUM formula (#3). Copy
from the Excel Formula Bar and paste into your posted response.

joeu2004
Guest
Posts: n/a

 18th Aug 2012
PS.... I wrote:
> "Wesler" <(E-Mail Removed)> wrote:
>> I am trying to get three different sums from the same range:
>> 1) All positive numbers
>> 2) All negative numbers
>> 3) The total (which I can get fine)
>> I tried this all kinds of ways, but the method below
>> works for the negative numbers, but give me an obscenely
>> high (and incorrect) number for the positive numbers:
>> Any ideas?

I cannot imagine how you can get a "method [that] works for the negative
numbers", but it does not work for the positive numbers. I suspect you are
misinterpreting your results for the negative numbers. Otherwise, simply
reverse the direction of your conditional expression. If you have "<0", use
">0".

joeu2004
Guest
Posts: n/a

 21st Aug 2012
"Wesler" <(E-Mail Removed)> wrote:
> Here's the function to get the negative numbers, which works.

[....]
> =SUMIF((F13),(K13),(P13),(U13),(Z13),(F28),(K28),(P28),(U28),(Z28),(K43),...,(Z193))"<0")

Sorry, but I do not believe you. What you posted is not syntactically
correct; of course, I removed ",...,(Z193)".

If you have a syntax question, you must show us the exact syntax by copying
from the Formula Bar and pasting into your posting, as I stated in my first
response in this thread. Obviously you did not do that.

Better still, upload an example Excel file (devoid of any private data) that
demonstrates the problem to a file-sharing website, and post the "shared",
"public" or "view-only" link (aka URL; http://...) in a response here. The
following is a list of some free file-sharing websites; or use your own.

Box.Net: http://www.box.net/files
Windows Live Skydrive: http://skydrive.live.com
MediaFire: http://www.mediafire.com
FileFactory: http://www.filefactory.com
FileSavr: http://www.filesavr.com
RapidShare: http://www.rapidshare.com

The example Excel file should have the formula that works for your.

In another cell, you should also include the formula you would like to make
work as text. For the latter, either set the cell format to Text before
typing the intended formula, or type an apostrophe before the initial equal
sign ("=") in the intended formula.

Don't forget to tell us where those cells are: the one with the formula
that works, and the one with intended formula as text.

joeu2004
Guest
Posts: n/a

 23rd Aug 2012
"Wesler" <(E-Mail Removed)> wrote:
> I've posted the a copy of the file:
> https://www.box.com/s/f338a6b474ebb6e761cb
>
> The formulae in question lie beside the first week's calendar
> Works for negative, doesn't for positive. It's odd.

Great! That explains a lot!

First, your syntax uses colon separators, not comma separators at you posted
previously, at least in my Excel (US English). AFAIK, that should be the
same in all regional Excels. I thought it is only the use of comma and
semicolon that differ.

In any case, the point is: Excel is taking your somewhat nonsensical syntax
and trying to make some sense of it. If you used the Evaluate Formula tool,
you would see that:

=SUMIF((F13)K13)P13)U13)Z13):[...]P193)U193)Z193),"<0")

is interpreted as

=SUMIF(\$F\$13:\$Z\$193,"<0")

It is important for you to understand that
(F13)K13)P13)U13)Z13):[...]P193)U193)Z193) is __not__ an
intentional way to specify a range, "broken" (sparse) or otherwise.

The parentheses are redundant and useless.

But even F13:K13:P13:U13:etc works only as an accident of implementation.
See the "operator" help page.

The colon is a "Range operator, which produces one reference to all the
cells between two references, including the two references (B5:B15)". Excel
has generalized that to behave like any other operator: a sequence of
pairwise "operations". Thus, it always produces a continuous ("unbroken")
range composed of the first and last cell references.

-----

Second, that correctly sums the negative values only coincidentally because
within the range F13:Z193, the only negative values are indeed the ones that
you want to sum.

In contrast, =SUMIF(\$F\$13:\$Z\$193,">0") does not sum correctly because within
the range F13:Z193, you have other non-negative values that you do not
intend to include in the sum, namely the dates in rows 17, 32, etc.

(But both sums might have been incorrect if you had legitimate negative or
positive values in the "vac" column, for example.)

If we can rely on the "X" strings in column A, the following is the correct
way for you to sum both positive and negative amounts.

=SUMPRODUCT((LEFT(A4:A194,1)="x")*(B3:Z3="xc")*(B4:Z194>0),B4:Z194)

=SUMPRODUCT((LEFT(A4:A194,1)="x")*(B3:Z3="xc")*(B4:Z194<0),B4:Z194)

I have expanded the rows and columns to be all-inclusive of the Oct through
Dec dates, and to make it easy for you to modify the formulas to sum other
types of columns, e.g. "vac".

If we cannot rely on the "X" strings in column A, I would suggest that you
insert a "helper" column with "X" strings. The helper column can be hidden.

joeu2004
Guest
Posts: n/a

 23rd Aug 2012
PS.... I wrote:
> If we can rely on the "X" strings in column A, the following is the
> correct way for you to sum both positive and negative amounts.
> =SUMPRODUCT((LEFT(A4:A194,1)="x")*(B3:Z3="xc")*(B4:Z194>0),B4:Z194)
> =SUMPRODUCT((LEFT(A4:A194,1)="x")*(B3:Z3="xc")*(B4:Z194<0),B4:Z194)

[....]
> If we cannot rely on the "X" strings in column A, I would suggest that you
> insert a "helper" column with "X" strings. The helper column can be
> hidden.

It just occurred to me that the "X" strings probably represent people's
names, which you prudently edited out of the example file.

But a helper column with "X" strings is not needed. The following should
produce the same results:

=SUMPRODUCT((A4:A194<>"")*(B3:Z3="xc")*(B4:Z194>0),B4:Z194)
=SUMPRODUCT((A4:A194<>"")*(B3:Z3="xc")*(B4:Z194<0),B4:Z194)

 Thread Tools Rate This Thread Rate This Thread: 5 : Excellent 4 : Good 3 : Average 2 : Bad 1 : Terrible

 Posting Rules You may not post new threads You may not post replies You may not post attachments You may not edit your posts BB code is On Smilies are On [IMG] code is On HTML code is OffTrackbacks are On Pingbacks are On Refbacks are Off Forum Rules

 Similar Threads Thread Thread Starter Forum Replies Last Post JPD Microsoft Excel Discussion 3 4th Feb 2010 09:31 PM tkw Microsoft Excel Misc 2 1st Oct 2009 09:17 PM PCLIVE Microsoft Excel Worksheet Functions 3 15th Jul 2009 07:43 PM markholt Microsoft Excel Worksheet Functions 3 28th Oct 2008 01:37 AM Oscar Microsoft Excel Worksheet Functions 2 12th Jan 2005 12:01 AM

Features