ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   Double Dash (https://www.excelbanter.com/excel-worksheet-functions/239141-double-dash.html)

Erin Searfoss

Double Dash
 
What does the double dash signify in a formula like this one I found in a
2006 post?

=SUMPRODUCT(--(X2:X500="foo"),--(Y2:Y500<100))

I've seen it muliple times and haven't quite figured it out. Thanks.

Gary''s Student

Double Dash
 
It converts a logical value (TRUE or FALSE) into a numerical value (1 or 0)
--
Gary''s Student - gsnu200860


"Erin Searfoss" wrote:

What does the double dash signify in a formula like this one I found in a
2006 post?

=SUMPRODUCT(--(X2:X500="foo"),--(Y2:Y500<100))

I've seen it muliple times and haven't quite figured it out. Thanks.


Jacob Skaria

Double Dash
 
J.E. McGimpsey has some notes at

http://mcgimpsey.com/excel/formulae/doubleneg.html

If this post helps click Yes
---------------
Jacob Skaria


"Erin Searfoss" wrote:

What does the double dash signify in a formula like this one I found in a
2006 post?

=SUMPRODUCT(--(X2:X500="foo"),--(Y2:Y500<100))

I've seen it muliple times and haven't quite figured it out. Thanks.


Erin Searfoss

Double Dash
 
Perfect. Thanks.

"Gary''s Student" wrote:

It converts a logical value (TRUE or FALSE) into a numerical value (1 or 0)
--
Gary''s Student - gsnu200860


"Erin Searfoss" wrote:

What does the double dash signify in a formula like this one I found in a
2006 post?

=SUMPRODUCT(--(X2:X500="foo"),--(Y2:Y500<100))

I've seen it muliple times and haven't quite figured it out. Thanks.


joeu2004

Double Dash
 
"Erin Searfoss" wrote:
What does the double dash signify in a formula like this one I found in a
2006 post?

=SUMPRODUCT(--(X2:X500="foo"),--(Y2:Y500<100))


Nothing special. It is simply an innocuous arithmetic operation (double
negation) that leaves the numeric result unchanged. For example, --5
= -(-5) = 5.

Some arithmetic operation is needed in order to treat the boolean result
(TRUE or FALSE) as a number (1 or 0) because SUMPRODUCT requires the latter.

But any valid arithmetic operation will have the same conversion effect.
For example, the above formula can be rewritten without "--" as:

=SUMPRODUCT((X2:X500="foo")*(Y2:Y500<100))



All times are GMT +1. The time now is 12:00 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com