Double Dash

E

Erin Searfoss

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.
 
G

Gary''s Student

It converts a logical value (TRUE or FALSE) into a numerical value (1 or 0)
 
J

JoeU2004

Erin Searfoss said:
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))
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top