Often you may want to use the COUNTA function with an IF function in Google Sheets to count the number of cells that are not empty only if a cell in a corresponding column meets a certain requirement.
Fortunately you can just use the COUNTIFS function to accomplish this.
The following example shows exactly how to do so.
Example: Using COUNTA with IF in Google Sheets
Suppose we have the following dataset that shows the points scored by various basketball players:
Suppose we would like to count the number of players with “Guard” in the Position column but only if the corresponding cell in the Points column is not empty.
We can type the following formula into cell D2 to calculate this number:
=COUNTIFS(A2:A16, "Guard", B2:B16, "<>"&"")
The following screenshot shows how to use this formula in practice:
The formula returns a value of 5.
This means that there are 5 players with a value of “Guard” in the Position column where the corresponding value in the Points column is not empty.
We can verify this is correct by manually identifying the five players that meet these criteria:
Each of the highlighted rows contains a player with a value of “Guard” in the Position column where the corresponding value in the Points column is not empty.
Note: You can find the complete documentation for the COUNTIFS function in Google Sheets here.
The following tutorials explain how to perform other common tasks in Google Sheets: