Forum Discussion

GrahamA1010's avatar
GrahamA1010
Copper Contributor
Jun 29, 2021
Solved

Countif function

I want to count the number of times "0" is found in 10 individual cells, not in a range. What is the formula ?
  • JMB17's avatar
    JMB17
    Jun 30, 2021

    GrahamA1010 

     

    Frequency will return an array with an element count 1 more than the bins_array argument (number of elements within the braces { }).

     

    I included -1E-25 as I wasn't sure if your data included negatives or decimals. So, -1E-25 should, I believe, group everything below 0. Then, the 0 element should capture the 0's as well as everything between it and the next element in the bins_array, but since it is the last element the frequency function automatically groups everything greater than it into another element (and is why the function always returns an array 1 element greater than the number of elements in bins_array).

     

    In this example, you can see frequency is returning 3 elements, everything below zero, zero, everything above zero. So, index is used to pull out the second element.

     

     

    If you're just dealing with integer data, then you should be able to count the 1's with:

    =INDEX(FREQUENCY((A1,A3,A5,A7,A9,A11,A13,A15,A17,A19),{0,1}),2)

     

    If decimal data, then I believe you could use:

    =INDEX(FREQUENCY((A1,A3,A5,A7,A9,A11,A13,A15,A17,A19),{0.999999999999999,1}),2)