Hello team,
Why -- does after sumProduct?
Regards,
Bita
Why do we use -- after sumproduct(--(A1:A7="somecreteria"))
-
- BronzeLounger
- Posts: 1498
- Joined: 01 Mar 2015, 02:03
-
- Administrator
- Posts: 78446
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: Why do we use -- after sumproduct(--(A1:A7="somecreteria"))
(A1:A7="somecreteria") returns an array of 7 TRUE/FALSE values: TRUE for each cell whose value is "somecreteria" and FALSE for all other cells.
So for example
{TRUE;FALSE;FALSE;TRUE;FALSE;TRUE;TRUE}
Excel ignores TRUE/FALSE in functions such as SUM and SUMPRODUCT. Using - forces Excel to treat TRUE/FALSE as numbers. TRUE is equivalent to 1 and FALSE to 0. -(A1:A7="somecreteria") turns the above array into
{-1;0;0;-1;0;-1;-1}
The second - changes the -1's to 1's: --(A1:A7="somecreteria") evaluates to
{1;0;0;1;0;1;1}
There is a 1 for each cell whose value is "somecreteria".
SUMPRODUCT adds the 1's, so the result is 4: the number of cells with "somecreteria".
So for example
{TRUE;FALSE;FALSE;TRUE;FALSE;TRUE;TRUE}
Excel ignores TRUE/FALSE in functions such as SUM and SUMPRODUCT. Using - forces Excel to treat TRUE/FALSE as numbers. TRUE is equivalent to 1 and FALSE to 0. -(A1:A7="somecreteria") turns the above array into
{-1;0;0;-1;0;-1;-1}
The second - changes the -1's to 1's: --(A1:A7="somecreteria") evaluates to
{1;0;0;1;0;1;1}
There is a 1 for each cell whose value is "somecreteria".
SUMPRODUCT adds the 1's, so the result is 4: the number of cells with "somecreteria".
Best wishes,
Hans
Hans
-
- BronzeLounger
- Posts: 1498
- Joined: 01 Mar 2015, 02:03
Re: Why do we use -- after sumproduct(--(A1:A7="somecreteria"))
Hans,
Thanks for all explanation, it is clear now.
Regards,
Bita
Thanks for all explanation, it is clear now.
Regards,
Bita