Hey,
Trying to decipher some Excel formulas and I see some stuff like SUMPRODUCT(--Left(...)...)
What is the -- doing? Naturally seems like decrementing to me but couldn't find any documentation on it.
Thanks.
Hey,
Trying to decipher some Excel formulas and I see some stuff like SUMPRODUCT(--Left(...)...)
What is the -- doing? Naturally seems like decrementing to me but couldn't find any documentation on it.
Thanks.
The unary operator (-) is a shorthand method to convert a true/false statement into -1/0.
A single operator will convert -(true) into -1, so a double unary operator is used to convert that back into 1:
-(-(true)) = -(-(1)) = 1
-(-(false)) = -(-(0)) = 0
I've been using SUMPRODUCT for a while and have always used the *
symbol instead of the --
. I'm sure I asked the same question you've asked, but I can't remember the reason they gave me, but I was told that there wasn't really a need for --
as sumproduct managed itself quite well without the it.
Anyway, =sumproduct(()*()*()*())
has always worked for me, and it's less confusing.