dengel3587
New Member
- Joined
- Jul 17, 2014
- Messages
- 2
I was having trouble with COUNTIF, so I fell upon this old thread:
http://www.mrexcel.com/forum/excel-questions/84490-countif-not-counting-all-values.html
In the third reply, fairwinds suggests using "=SUMPRODUCT(--(A1:A10={"y","n","n/a"}))" instead of COUNTIF.
For reasons I don't know, using that "--( )" fixed my problem. Specifically, my problem was I was trying to count the number of times "<-50%" appeared in some cells. The list looked something like this:
<TBODY>
</TBODY>Using
=COUNTIF($A$1:$A$5, <criteria> )
worked for things like "0%" and "-20 to -25%", but it didn't work for "<-50%". Then when I used
=SUMPRODUCT(--($A$1:$A$5="<-50%"))
it worked. What does the "--( )" do that makes this^ formula work, but not the COUNTIF or using the SUMPRODUCT without the "--( )" part.
http://www.mrexcel.com/forum/excel-questions/84490-countif-not-counting-all-values.html
In the third reply, fairwinds suggests using "=SUMPRODUCT(--(A1:A10={"y","n","n/a"}))" instead of COUNTIF.
For reasons I don't know, using that "--( )" fixed my problem. Specifically, my problem was I was trying to count the number of times "<-50%" appeared in some cells. The list looked something like this:
A | |
1 | 0% |
2 | -20 to -25% |
3 | +20 to +25% |
4 | 0 to +5% |
5 | <-50% |
<TBODY>
</TBODY>
=COUNTIF($A$1:$A$5, <criteria> )
worked for things like "0%" and "-20 to -25%", but it didn't work for "<-50%". Then when I used
=SUMPRODUCT(--($A$1:$A$5="<-50%"))
it worked. What does the "--( )" do that makes this^ formula work, but not the COUNTIF or using the SUMPRODUCT without the "--( )" part.