I’d like to multiply a set of numbers by a set of Booleans element-by-element and get the sum. For example,
SUM([10, 20, 30] .* [TRUE, FALSE, TRUE]) = SUM([10, 0, 30]) = 40
Is there a way to do this in Calc?
I’d like to multiply a set of numbers by a set of Booleans element-by-element and get the sum. For example,
SUM([10, 20, 30] .* [TRUE, FALSE, TRUE]) = SUM([10, 0, 30]) = 40
Is there a way to do this in Calc?
Yes. SUMPRODUCT ( { 10 ; 20 ; 30 } ; { TRUE ; FALSE ; TRUE } )
will do.
See attached file which demonstrates this calculation on inline data (as per your request) as well as on a cell range.
I’d upvote this if I had enough reputation. This is exactly what I needed. Thanks for the quick response!