use:
=ARRAYFORMULA(COUNTIFS(Data!B:B, "*"&D2:D21&"*", Data!B:B, "*"&E2:E21&"*"))

I created a super simple table where one column has “Yes” or “No” entered in each cell. At the bottom of the list, I entered =COUNTIF(B2:B84, “Yes”) to find out how many “yes”s I had. It keeps saying “formula parse error”. I can’t figure it out.
Here’s a link to my sheet:
yes/no table
0 is correct because with each new criteria_range you are ANDing the results (i.e. your formula as shown is equivalent to 'give me the count where there is a TRUE present in the same position in each column').
If you want to return 5, that implies to me that you actually want 'give me the count of TRUEs across all rows', in which case you should stack the columns into one using array literals:
=countif({D8:D16;H8:H16;L8:L16;P8:P16;T8:T16},true)
Use SUM and FILTER
This aporoach uses a single range and is easy to reuse and manage. It leverages the consistent column pattern found in your sample data.
Formula
=SUM(FILTER(D8:T16*1, NOT(MOD(
SEQUENCE(1,COLUMNS(D8:T16),0),4))))
Explanation
- FILTER is applied to the range
D8:T16to remove columns that aren't wanted. - All the values in the range
D8:T16are multiplied by1so Sheets will coerce the checkbox values fromTRUEandFALSEto1and0. - The FILTER's condition argument includes only every fourth column starting with the first. This is achieved by:
- Creating a one row SEQUENCE of numbers based on the number of columns in the range, starting at
0and incrementing by1 - Wrapping the SEQUENCE in MOD using
4as the divisor, which changes the number SEQUENCE:# before MOD {0,1,2,3,4,5,6,7,8,9,10,11,12,...} # after MOD {0,1,2,3,0,1,2,3,0,1,2,3,0,...} - MOD is then wrapped in NOT to convert the values
0,1,2,3toTRUE,FALSE,FALSE,FALSE. Now the position of allTRUEvalues in the FILTER condition matches the position of the columns that should be counted.
- Creating a one row SEQUENCE of numbers based on the number of columns in the range, starting at
- Lastly, SUM is used to total all values from the array of ones and zeros returned by the FILTER. This is equivalent to counting.
I’m trying to make =COUNTIF work with numbers but it either comes up blank or as 0
You have separate Columns for "Date Due" and "Time Due" and you are creating a ranking (using countifs) by adjusting for date and time. You have found that the ranking is producing unexpected errors and don't know why.
Your formula is"
={"Priority"; ARRAYFORMULA(if(isblank(J2:J),if(isblank(H2:H)=false,
countifs(J:J,"",H:H,"<="&H2:H)
-countifs(J:J,"",H:H,H2:H,I:I,">"&I2:I),""),""))}
The error arises as a result of adjusting for Time independent of the Date. Date and Time are both Date Objects. In a Google Spreadsheet function, both are calculated as a decimal value relative to the epoch (12/30/1899 0:00:00), though formatting can is often used to mask this.
In your formula you calculate an adjustment between the count of Dates (Column H) less the count of Times (Column I). However, this assumes that both values exist in the same sequence - this is not the case. These Times are unrelated to their Date counterparts - they exist in isolation and thus the calculation is affected by their relative value (rather than an absolute value).
The solution to the problem is twofold:
- record the Due Date as a Date/Time, and
use
COUNIFSbased on the Date/Time field only (delete the element-countifs(J:J,"",H:H,H2:H,I:I,">"&I2:I))OR
use the
RANKfunction (sorting descending).
This table shows the effect on the decimal value of the Time when taken in isolation compared to when taken as a Date/Time value).

The logic and reasoning expressed by Tedinoz is correct. The proposed solutions work as well.
Still. One can follow a different approach.
The problem is that in your second COUNTIFS condition you are mixing dates and times therefore the incompatibility giving false results.
Easily corrected by slightly tweaking your formula.
You just need to replace the two mentions of column I with H+I
={"Priority";
ARRAYFORMULA(if(isblank(J2:J),
if(isblank(H2:H)=false,
countifs(J:J,"",H:H,"<="&H2:H)
-countifs(J:J,"",H:H,H2:H,H:H+I:I,">"&H2:H+I2:I) ,""),""))}
This way you create a virtual timestamp taking into account both the given date as well as the time of the date (avoiding using an extra helper column along with deleting the second COUNTIFS or radically changing your formula using the RANK function).
As an extra bonus you get to keep all columns intact since you "need those columns separate for functionality in the rest of the workbook".
The virtual timestamp works because using eg. H194+I194 (where H194 is a date 03/09/2020 and I194 is a time 8:33:00 PM), Google Sheets are smart enough NOT to just add these two cells as numeric values but to concatenate them and create the timestamp 3/9/2020 20:33:00
I have a list, then below a =UNIQUE to populate a list and =Countif to count the instances of each name.
But the count is off. Why?
Here's the sheet:
https://docs.google.com/spreadsheets/d/1hy7Yuy6uHvtHIhzc7wkdUX4IkBrtKw74RINycz5l2D4/edit?usp=sharing
See Also: Count rows with not empty value
Unfortunately, this is functions as designed from Google.
Although I'm not sure why it's divergent from the way that Excel calculates COUNTA.
According to the Google Spreadsheet Documentation on COUNTA:
COUNTA counts all values in a dataset, including those which appear more than once and text values (including zero-length strings and whitespace).
Meaning that the only way to "make [the cells] completely empty" is to delete the entire contents, formula and all. But fear not...
Some workarounds:
Hypothetically, you should be able to do this with
=COUNTIF(A3:A8,"<>"&""), but Google spreadsheets doesn't support the not equal to operator in the COUNTIF function according to these forums: 1, 2, 3A workaround is to create a truthy or falsy array based on the condition and use SUMPRODUCT to count the truthy values like this:
=SUMPRODUCT((A3:A8<>"")*1)Another option you could pursue would be to write a custom function and add it to Drive.
It's actually pretty easy to do so. Go to Tools > Script Editor and add the following script:/** * Works like COUNTA except does not include null strings * * @param {cellRange} myArray The value or range to consider when counting. * @return Returns the a count of the number of values in a dataset. * @customfunction */ function CountNotBlank(myArray) { var output = 0; for (i = 0; i < myArray.length; i++) { if (myArray[i] != "") { output += 1 } } return output; }Then use like this:
=CountNotBlank(I31:I)
I would try: =IF(ISNUMBER(D31), "X", iferror(1/0))
I am told that the iferror(1/0) returns nothing at all.