Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Patty via OfficeKB.com
 
Posts: n/a
Default sumproduct between 2 ranges

I want to count the number of cells whose values fall between 0.40 and 0.61.
I did

=SUMPRODUCT((M3:M200.4)-(M3:M20<0.61))

but the result is not the same as when I manually count the number of cells
so the formula is clearly wrong.

how do I fix?


--
Message posted via http://www.officekb.com
  #2   Report Post  
Dave Peterson
 
Posts: n/a
Default

One way:

=SUMPRODUCT(--(M3:M200.4),--(M3:M20<0.61))

=sumproduct() likes to work with numbers. The -- changes true/false to +1/0.

"Patty via OfficeKB.com" wrote:

I want to count the number of cells whose values fall between 0.40 and 0.61.
I did

=SUMPRODUCT((M3:M200.4)-(M3:M20<0.61))

but the result is not the same as when I manually count the number of cells
so the formula is clearly wrong.

how do I fix?

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


--

Dave Peterson
  #3   Report Post  
Earl Kiosterud
 
Posts: n/a
Default

Dave,

Side note. For some reason, if you multiply the expressions yourself (use
an asterisk multiply operator), the resulting TRUE or FALSE values of each
boolean expression get coerced to 1 or 0 automatically, and you don't need
the double negation operators:

=SUMPRODUCT( (M3:M200.4) * (M3:M20<0.61) )

In this case we're not really using the PRODUCT part of SUMPRODUCT, since
there's only one argument. It's just a handy array-SUM function.

But if we provide it with two arguments, letting it do the multiplication:

=SUMPRODUCT( (M3:M200.4), (M3:M20<0.61) )

It doesn't seem to coerce the resulting TRUE or FALSE values to 1 or 0
before it does the multiply. So we have to use the double-negation to force
the coercion.

=SUMPRODUCT(--(M3:M200.4),--(M3:M20<0.61))

I don't know why. I'm just a pawn in the great game of life.

--
Earl Kiosterud
www.smokeylake.com

"Dave Peterson" wrote in message
...
One way:

=SUMPRODUCT(--(M3:M200.4),--(M3:M20<0.61))

=sumproduct() likes to work with numbers. The -- changes true/false to
+1/0.

"Patty via OfficeKB.com" wrote:

I want to count the number of cells whose values fall between 0.40 and
0.61.
I did

=SUMPRODUCT((M3:M200.4)-(M3:M20<0.61))

but the result is not the same as when I manually count the number of
cells
so the formula is clearly wrong.

how do I fix?

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


--

Dave Peterson



  #4   Report Post  
Dave Peterson
 
Posts: n/a
Default

From what I've read, the -- version is slightly faster (generally).

And I actually find it easier to understand how the product and sum work in the
=sumproduct() function!

Earl Kiosterud wrote:

Dave,

Side note. For some reason, if you multiply the expressions yourself (use
an asterisk multiply operator), the resulting TRUE or FALSE values of each
boolean expression get coerced to 1 or 0 automatically, and you don't need
the double negation operators:

=SUMPRODUCT( (M3:M200.4) * (M3:M20<0.61) )

In this case we're not really using the PRODUCT part of SUMPRODUCT, since
there's only one argument. It's just a handy array-SUM function.

But if we provide it with two arguments, letting it do the multiplication:

=SUMPRODUCT( (M3:M200.4), (M3:M20<0.61) )

It doesn't seem to coerce the resulting TRUE or FALSE values to 1 or 0
before it does the multiply. So we have to use the double-negation to force
the coercion.

=SUMPRODUCT(--(M3:M200.4),--(M3:M20<0.61))

I don't know why. I'm just a pawn in the great game of life.

--
Earl Kiosterud
www.smokeylake.com

"Dave Peterson" wrote in message
...
One way:

=SUMPRODUCT(--(M3:M200.4),--(M3:M20<0.61))

=sumproduct() likes to work with numbers. The -- changes true/false to
+1/0.

"Patty via OfficeKB.com" wrote:

I want to count the number of cells whose values fall between 0.40 and
0.61.
I did

=SUMPRODUCT((M3:M200.4)-(M3:M20<0.61))

but the result is not the same as when I manually count the number of
cells
so the formula is clearly wrong.

how do I fix?

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


--

Dave Peterson


--

Dave Peterson
  #5   Report Post  
Earl Kiosterud
 
Posts: n/a
Default

Dave,

I agree. It's a little weird to be using SUMPRODUCT, then still have to use
multiply operators. It also seems odd that when using two or more arguments
(your way), it doesn't coerce the TRUE and FALSE. Why do I hear Twilight
Zone music in the background?
--
Earl Kiosterud
www.smokeylake.com

Off topic: Anyone who hasn't Men in Coats,
http://www.koreus.com/files/200505/men-in-coats.html should do so. It's a
riot.

----------------------------------------------------------------------------------------

"Dave Peterson" wrote in message
...
From what I've read, the -- version is slightly faster (generally).

And I actually find it easier to understand how the product and sum work
in the
=sumproduct() function!

Earl Kiosterud wrote:

Dave,

Side note. For some reason, if you multiply the expressions yourself
(use
an asterisk multiply operator), the resulting TRUE or FALSE values of
each
boolean expression get coerced to 1 or 0 automatically, and you don't
need
the double negation operators:

=SUMPRODUCT( (M3:M200.4) * (M3:M20<0.61) )

In this case we're not really using the PRODUCT part of SUMPRODUCT, since
there's only one argument. It's just a handy array-SUM function.

But if we provide it with two arguments, letting it do the
multiplication:

=SUMPRODUCT( (M3:M200.4), (M3:M20<0.61) )

It doesn't seem to coerce the resulting TRUE or FALSE values to 1 or 0
before it does the multiply. So we have to use the double-negation to
force
the coercion.

=SUMPRODUCT(--(M3:M200.4),--(M3:M20<0.61))

I don't know why. I'm just a pawn in the great game of life.

--
Earl Kiosterud
www.smokeylake.com

"Dave Peterson" wrote in message
...
One way:

=SUMPRODUCT(--(M3:M200.4),--(M3:M20<0.61))

=sumproduct() likes to work with numbers. The -- changes true/false to
+1/0.

"Patty via OfficeKB.com" wrote:

I want to count the number of cells whose values fall between 0.40 and
0.61.
I did

=SUMPRODUCT((M3:M200.4)-(M3:M20<0.61))

but the result is not the same as when I manually count the number of
cells
so the formula is clearly wrong.

how do I fix?

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

--

Dave Peterson


--

Dave Peterson





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
Another Sumproduct & #N/A problem Dave Davis Excel Worksheet Functions 3 January 10th 05 03:59 PM
Sumproduct function not working Scott Summerlin Excel Worksheet Functions 12 December 4th 04 05:15 AM
compare unique identifiers in multiple ranges bawilli_91125 Charts and Charting in Excel 1 November 30th 04 06:34 PM
Named dynamic ranges, copied worksheets and graph source data WP Charts and Charting in Excel 1 November 28th 04 05:19 PM
adding two sumproduct formulas together ski2004_2005 Excel Worksheet Functions 1 November 12th 04 09:08 PM


All times are GMT +1. The time now is 12:47 PM.

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

About Us

"It's about Microsoft Excel"