The Google Sheets function COUNTIF is a powerful tool used to calculate the number of cells within a specified range that meet a given condition. This function is particularly useful for data analysis, enabling users to easily summarize information based on specified criteria.
Syntax
COUNTIF(range, criterion)
- range: The group of cells that you want to evaluate.
- criterion: The condition that must be met for a cell to be counted. This can be a number, expression, or text string.
Example #1
COUNTIF(A1:A10, "Apple")
The function counts how many cells in the range A1 to A10 contain the word “Apple.” For example, if cells A1, A3, and A7 contain “Apple,” the result would be 3.
Example #2
COUNTIF(B1:B10, ">10")
This counts the number of cells in the range B1 to B10 that are greater than 10. If three cells meet this criterion, the output will be 3.
Example #3
COUNTIF(C1:C10, "<>0")
Here, the function counts all the cells in C1 to C10 that do not equal zero. If there are five cells containing non-zero values, the result will be 5.
Error handling
- VALUE! – This error occurs when the supplied range is not valid, possibly due to incorrect data types.
- REF! – This indicates that the range specified refers to a cell or range that is not valid, often due to deleted cells.
- N/A – This error may appear if the criterion specified cannot be evaluated, typically due to logical inconsistencies in the input.