#1   Report Post  
Posted to microsoft.public.excel.newusers
external usenet poster
 
Posts: 30
Default SUMPRODUCT

Hi, cany anyone tell me why the following SUMPRODUCT Formula works

=SUMPRODUCT(--(MONTH(CountDate)=MONTH(B$2)),--(AreaCol=$A4),--
(SRACol=0.98),--(SRACol<=1.02))

Result is 195 which is correct.

And this one doesn't

=SUMPRODUCT(--(MONTH(CountDate)=MONTH(B$2)),--(AreaCol=$A4),--
(SRACol<0.98),--(SRACol1.02))

Result is 0, should be 16. If I only include one search for <0.98 or
1.02 then I get 7 + 9 respectively. Why does it not work when they

are combined as in the first formula.

Regards

Peter

  #2   Report Post  
Posted to microsoft.public.excel.newusers
external usenet poster
 
Posts: 829
Default SUMPRODUCT

"Pete" wrote:
cany anyone tell me why the following SUMPRODUCT Formula works
=SUMPRODUCT(--(MONTH(CountDate)=MONTH(B$2)),--(AreaCol=$A4),
--(SRACol=0.98),--(SRACol<=1.02))

Result is 195 which is correct.

And this one doesn't
=SUMPRODUCT(--(MONTH(CountDate)=MONTH(B$2)),--(AreaCol=$A4),
--(SRACol<0.98),--(SRACol1.02))

Result is 0, should be 16. If I only include one search for <0.98 or
1.02 then I get 7 + 9 respectively. Why does it not work when they

are combined as in the first formula.


When you use SUMPRODUCT in this form, you are implicitly specifying the
"and" of all conditions.

So the first SUMPRODUCT counts the number of instances when CountDate is the
same month as B2 __and__ AreaCol equals A4 __and__ SRACol is between 0.98
and 1.02 inclusive, all in the same row or column.

Likewise, as written, the second SUMPRODUCT counts when CountDate is the
same month as B2 __and__ AreaCol equals A4 __and__ SRACol is both less than
0.98 __and__ greater than 1.02.

Obviously the latter condition is not what you intended. Zero is the
correct answer since SRACol cannot meet both conditions at the same time.

I suspect that what you want is:

=SUMPRODUCT(--(MONTH(CountDate)=MONTH(B$2)),--(AreaCol=$A4),
--((SRACol<0.98)+(SRACol1.02)0))

The plus ("+") behaves almost like OR, especially when we include "0".
(Although in this case, "0" is not necessary because the two conditions are
mutually-exclusive.)

By the way, multiply ("*") behaves like AND. So you could write:

=SUMPRODUCT((MONTH(CountDate)=MONTH(B$2))*(AreaCol =$A4)
*((SRACol<0.98)+(SRACol1.02)0))

A few less characters to type.


  #3   Report Post  
Posted to microsoft.public.excel.newusers
external usenet poster
 
Posts: 829
Default SUMPRODUCT

PS....

I wrote:
I suspect that what you want is:
=SUMPRODUCT(--(MONTH(CountDate)=MONTH(B$2)),--(AreaCol=$A4),
--((SRACol<0.98)+(SRACol1.02)0))

[....]
So you could write:
=SUMPRODUCT((MONTH(CountDate)=MONTH(B$2))*(AreaCol =$A4)
*((SRACol<0.98)+(SRACol1.02)0))


There is always some question about whether one form performs better than
the other.

I measured this some time ago; but frankly, I don't remember the answer.

However, it usually does not matter unless and until CountDate et al
encompass tens of thousands of rows and/or you replicate this formula in
thousands of cells.

Generally, use whichever form you feel more comfortable unless and until you
encounter some performance bottleneck.

Then you might try the other form to see if it makes a difference. In my
experience, it does not because the real performance bottleneck is simply
the fact that we doing so many recalculations in the first place.

  #4   Report Post  
Posted to microsoft.public.excel.newusers
external usenet poster
 
Posts: 30
Default SUMPRODUCT

Many thanks for the Formula and the explanation, much appreciated and
exactly what I wanted.

Regards

Pete
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Sumproduct blkane Excel Worksheet Functions 3 October 20th 09 07:12 PM
Sumproduct with Condition OR Sumproduct with ADDRESS function - HE gholly Excel Discussion (Misc queries) 2 September 28th 09 05:07 PM
Conditional SUMPRODUCT or SUMPRODUCT with Filters Ted M H Excel Worksheet Functions 4 August 14th 08 07:50 PM
sumproduct? sumif(sumproduct)? David Excel Worksheet Functions 3 July 13th 07 07:06 PM
SUMPRODUCT help [email protected] Excel Worksheet Functions 3 October 18th 06 11:00 PM


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

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

About Us

"It's about Microsoft Excel"