• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

hyphen

daphne

New Member
new to excel
was checking out the sumproduct article
what is the hypen (2 dashes) in the formula for
=SUMPRODUCT(--(A1:A10="Luke Skywalker"),--(B1:B10="West"),D1:D10)
 
Hi, daphne!
The trick of the 2 dahses, 2 minus signs in fact, is to convert logical values (true, false) into numeric values, and hence allowing to perform arithmetic operations.
There's another way to do that, and it's multiplying (as the main operation of the SUMPRODUCT function, sum of products) each matrix instead of separating them by commas:
=SUMPRODUCT((A1:A10="Luke Skywalker")*(B1:B10="West")*(D1: D10))
Hope it helps.
Regards!
 
Hi Daphne,
Adding to SirJB7's comment, in Excel a TRUE value is equivalent to a value of 1, while a FALSE value is equivalent to a value of 0 (zero).

The 2 dashes are actually two minus signs. A single minus sign forces Excel to evaluate a value (such as TRUE or FALSE) to return a number (-1 or 0). By adding a second minus sign, the value is negated.
For example, -(TRUE) returns -1.
--(TRUE) returns 1

(A1:A10="Luke Skywalker") is a comparison that returns values of TRUE;FALSE;etc.

The double negation (i.e. --) converts those values into the corresponding 1s and 0s.

Hope that helps.

-Sajan.
 
Hi, daphne!
Glad you solved it. Thanks for your feedback and for your kind words too. And welcome back whenever needed or wanted.
Regards!

@Sajan
Hi!
Thanks for the true/false equivalence which I omitted.
Regards!
 
Daphne, You are very welcome.

SirJB7, I had not seen your post until after I posted a reply.
 
Back
Top