Numerical value of logicals

H

hmm

As I understand it, when logicals are used in a formula, TRUE=1 and FALSE=0.
If this is so, then why is Excel evaluating the formula below as 0 instead of
1?

=SUMPRODUCT({FALSE,TRUE,FALSE},{TRUE,TRUE,FALSE})
 
B

Bernard Liengme

You need to coerce the Boolean into numeric with an arithmetic operation.
Here are two example; each gives result of 1.

1) =SUMPRODUCT(--{FALSE,TRUE,FALSE}, --{TRUE,TRUE,FALSE})
This uses the unary negation operator (-) twice
2) =SUMPRODUCT({FALSE,TRUE,FALSE}*{TRUE,TRUE,FALSE})
This uses multiplication which is what
=SUMPRODUCT({FALSE,TRUE,FALSE}, {TRUE,TRUE,FALSE}) is expected to do but
does not!
 
A

Ashish Mathur

Hi,

Try this instead. The double dash signs coerce TRUE to 1 and FALSE to 0.

SUMPRODUCT(--{FALSE,TRUE,FALSE},--{TRUE,TRUE,FALSE})

--
Regards,

Ashish Mathur
Microsoft Excel MVP
www.ashishmathur.com
 

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