I have an array, which is the result of the multiplication of two COUNTIF functions.
The result is {0,2,7,4,0}. I want to count the number of non-zero elements. I tried the following:
=COUNTIF(COUNTIF*COUNTIF,">0") <- here the two inner COUNTIFs are short for the complete formula
It did not work. I then tried the following, which did not work either.
=COUNTIF({0,2,7,4,0},">0")
I resorted to using the following array formula and it worked.
{=SUM(IF(COUNTIF*COUNTIF>0,1,0))}
Two questions:
Thanks.
The first argument of COUNTIF must be a range, nothing else will do.
You can just enter this as an ordinary formula:
=SUM(--({0,2,7,4,0}>0))
However when the array comes from a calculation, you need to coerce it to process all the elements either
=SUM(INDEX(--(A1:A5>0),0))
or like @Jeeped with Sumproduct
=SUMPRODUCT(--(A1:A5>0))
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.