H
Hari
Hi,
1. Just read http://www.mcgimpsey.com/excel/formulae/doubleneg.html
In this JEM says that we have double negs so that
=SUMPRODUCT(--(A1:A5>10),B1:B5))
can be coerced in to 1. As per JEM"s explanation single unary will coerce
True/False to Zero/One and the second double unary is used so that the
negative values could be converted to its original sign. My "reasoning" was
instead of using double negative sign why not use a single + sign and
achieve further speed increase.
So I did this =SUMPRODUCT(--(A1:A5>5),--(A1:A5<10),B1:B5) . The data I used
was
A B
2 3
3 4
11 5
5 6
6 10
SADLY, got the answer as Zero. I used evaluate formula feature to see why
excel wasnt coercing true, false to 1,0 by seeing the "+" sign.
But couldnt understsand it. Why cant a single plus sign achieve that?
2.(I did not accept defeat with the above and now tried a diff. approach.).
Suppose the number of conditions to evaluate is 2. Like above we are
checking for 2 conditions A1:A5>5 and A1:A5<10 and in all using 4 negs. I
think it can be reduced to 2 negs in the following way..
=SUMPRODUCT(-(A1:A5>5),-(A1:A5<10),B1:B5). This way when we have EVEN number
of conditions then use the unary operator only once for each condition so
that net effect of minus cancels out.
What if we have ODD number of conditions.? For that, for one condition we
will keep it as double negs and for the rest it will be single negs.
I think that there could be slightly more tweaking of even ODD condition.
Just lie EVEN case for all conditions take it as single neg and then in
front of sumproduct put a Negative sign in order to get the correct result
for the final evaluation.
Like suppose we have to check for 3 conditions, with A1:A5>5, A1:A5<10 and
A1:A5> average(A1:A5)
then write the formula as
= -SUMPRODUCT(-(A1:A5>5),-(A1:A5<10),-(A1:A5> Average(A1:A5)),B1:B5).
Am I talking sense here?
Regards,
Hari
India
1. Just read http://www.mcgimpsey.com/excel/formulae/doubleneg.html
In this JEM says that we have double negs so that
=SUMPRODUCT(--(A1:A5>10),B1:B5))
can be coerced in to 1. As per JEM"s explanation single unary will coerce
True/False to Zero/One and the second double unary is used so that the
negative values could be converted to its original sign. My "reasoning" was
instead of using double negative sign why not use a single + sign and
achieve further speed increase.
So I did this =SUMPRODUCT(--(A1:A5>5),--(A1:A5<10),B1:B5) . The data I used
was
A B
2 3
3 4
11 5
5 6
6 10
SADLY, got the answer as Zero. I used evaluate formula feature to see why
excel wasnt coercing true, false to 1,0 by seeing the "+" sign.
But couldnt understsand it. Why cant a single plus sign achieve that?
2.(I did not accept defeat with the above and now tried a diff. approach.).
Suppose the number of conditions to evaluate is 2. Like above we are
checking for 2 conditions A1:A5>5 and A1:A5<10 and in all using 4 negs. I
think it can be reduced to 2 negs in the following way..
=SUMPRODUCT(-(A1:A5>5),-(A1:A5<10),B1:B5). This way when we have EVEN number
of conditions then use the unary operator only once for each condition so
that net effect of minus cancels out.
What if we have ODD number of conditions.? For that, for one condition we
will keep it as double negs and for the rest it will be single negs.
I think that there could be slightly more tweaking of even ODD condition.
Just lie EVEN case for all conditions take it as single neg and then in
front of sumproduct put a Negative sign in order to get the correct result
for the final evaluation.
Like suppose we have to check for 3 conditions, with A1:A5>5, A1:A5<10 and
A1:A5> average(A1:A5)
then write the formula as
= -SUMPRODUCT(-(A1:A5>5),-(A1:A5<10),-(A1:A5> Average(A1:A5)),B1:B5).
Am I talking sense here?
Regards,
Hari
India