APPS • DAILYTECH.ID - The COUNTIF function in Google Sheets is used to count the number of cells within a specified range that satisfy a single given criterion. The essential syntax is =COUNTIF(range, criterion). The criterion can include exact numbers, quoted text strings, logical operators like ">50", or cell references. For applying multiple criteria simultaneously (AND logic), the related function COUNTIFS must be used.
The COUNTIF function is a foundational tool for data analysis in Google Sheets, enabling rapid quantification of data points based on specific criteria. This guide explores the foundational and advanced applications of conditional counting, ensuring you can efficiently analyze any dataset using COUNTIF and COUNTIFS.
Mastering the COUNTIF Function Basics in Google Sheets
The core requirement for modern data analysis is the ability to quantify specific subsets within a larger dataset. Whether you are tracking completed projects, counting sales above a certain threshold, or determining how many records are marked “Pending,” the ability to conditionally count is indispensable. This crucial task is expertly managed by the COUNTIF function in Google Sheets. Understanding the syntax and its initial application is the first step toward unlocking robust sheet analysis and efficiently summarizing large amounts of data.
Basic Syntax and Structure: How to Use COUNTIF
The primary formula structure for counting based on one condition remains consistent and straightforward: =COUNTIF(range, criterion). This structure is the fundamental google sheet countif formula upon which all basic conditional counting is built.
range: This defines the continuous set of cells (e.g., A2:A100, or an entire column like C:C) that the function will evaluate.criterion: This specifies the condition that must be met for a cell to be counted. This can be a number, a text string, or a comparison expression.
For example, if you want to know how many cells in column A contain the exact number 15, the formula is simple: =COUNTIF(A:A, 15).
Counting Specific Values (Numbers, Text, and Cell References)
The power of the countif function in google sheet lies in its flexibility to handle various data types.
Counting Text: When counting exact text strings, the criterion must be enclosed in double quotes. For instance, if you are analyzing a status column (B:B) and want to count how many items are marked “Complete,” your formula would be: =COUNTIF(B:B, "Complete"). Note that COUNTIF is generally case-insensitive for text matching.
Counting Numbers and Operators: Numerical criteria can be entered directly (e.g., 100). More commonly, you will use logical operators (<, >, <=, >=, <>) to perform comparisons. When a logical operator is involved, the entire comparison must be enclosed in quotes.
| Scenario | Keyword Intent | Example Formula |
|---|---|---|
| Greater than zero | google sheet countif greater than 0 | =COUNTIF(C:C, ">0") |
| Less than 50 | google sheet countif less than | =COUNTIF(D:D, "<50") |
| Not equal to 10 | google sheet countif not equal | =COUNTIF(E:E, "<>10") |
Using Cell References: Crucially, the criterion can also reference another cell, allowing for dynamic counting without altering the formula itself. If cell F1 contains the threshold value (e.g., 500) you want to count against, you must concatenate the operator with the cell reference. This is a common point of error for beginners.
Formula Example (Dynamic Comparison): To count how many values in G:G are greater than the value in cell F1: =COUNTIF(G:G, ">"&F1).
How to COUNTIF for Not Blank or Not Empty Cells
A frequent requirement in data cleanup and analysis is counting cells that contain any data. While Google Sheets offers the COUNTA function to count all non-empty cells in a range, you can also achieve this using COUNTIF with a logical operator.
To implement the google sheet countif not blank or google sheet count if cell is not empty logic, we use the “not equal to” operator (<>) combined with an empty string (“”).
Formula Example (Not Empty):
To count cells in column A that are not empty: =COUNTIF(A:A, "<>").
Conversely, to count cells that are explicitly blank or empty (often needed to track gaps in data):
Formula Example (Explicitly Empty):=COUNTIF(A:A, "").
Advanced COUNTIF: Handling Text and Partial Matches
When processing textual data, requiring an exact match is often too restrictive. Data points frequently contain extra descriptors, identifying codes, or minor variations. This is where the ability to count based on partial text matching—using wildcards—becomes essential for effective data mining using COUNTIF.
Counting Cells That Contain Specific Text (Wildcard Usage)
Google Sheets utilizes powerful wildcards within the COUNTIF function to perform partial match counting. The asterisk (*) is the primary wildcard, representing any sequence of zero or more characters. This enables the robust functionality for the user looking for google sheet countif contains text.
General Wildcard Rules:
- Asterisk (
*): Matches any sequence of characters (including no characters). - Question Mark (
?): Matches any single character.
Example (Contains Partial Text):
To count cells in B:B that contain the word “Project” anywhere within the cell, regardless of what precedes or follows it:=COUNTIF(B:B, "*Project*")
This formula is critical for satisfying the search intent around google sheets count if a cell contains text and google sheet countif wildcard. It ensures that entries like “Q4 Project Summary” and “Final Project Draft” are both counted.
Counting Cells That Start With or End With a String
Wildcards can be positioned strategically to define boundaries for your counting criteria:
- Starts With: To count entries that start with a specific term (e.g., “ID-“), place the wildcard at the end. This counts any entry beginning with “ID-” followed by anything else.
=COUNTIF(C:C, "ID-*") - Ends With: Conversely, to count entries that end with a term (e.g., “-Draft”), place the wildcard at the beginning. This counts entries where the preceding text is irrelevant, but the entry must conclude with the specified string.
=COUNTIF(C:C, "*-Draft")
COUNTIFS: Counting with Multiple Criteria (AND Logic)
When your analysis requires filtering data based on two, three, or even more simultaneously true conditions, the single criterion limit of COUNTIF is insufficient. This is the moment to transition to the plural form: the COUNTIFS function. COUNTIFS is specifically designed to handle “AND” logic, meaning a cell is only counted if all specified conditions are met.
Syntax for COUNTIFS: Using Multiple Ranges and Criteria
The structure of COUNTIFS differs slightly from COUNTIF because it expects pairs of ranges and criteria: =COUNTIFS(range1, criterion1, range2, criterion2, range3, criterion3, ...)
The function allows for an almost unlimited number of range/criterion pairs. The key syntax rule is that the ranges must be of the same size, and the criteria must be exactly what you would use inside a standard COUNTIF.
Example (Two Conditions):
Suppose you need to find the number of “High Priority” items in Column A that also have an “Open” status in Column B. This satisfies the search for google sheet count if two conditions.
=COUNTIFS(A:A, "High Priority", B:B, "Open")
Example (Three Conditions):
To fulfill the google sheets countifs 3 criteria requirement, we might add a third check for a responsible party in Column C:=COUNTIFS(A:A, "High Priority", B:B, "Open", C:C, "Jane Doe")
Using COUNTIFS for Numerical or Date Ranges
The most critical and common application of COUNTIFS is defining a range between two values, whether they are numbers or dates. Because conditional counting functions only accept single operators per criterion, defining a range requires setting the upper bound and the lower bound as two separate conditions operating on the same data range.
Example (Counting Between Two Numbers):
To count all order totals in D:D that are between 50 and 100 (inclusive), you need two criteria applied to range D:D: one check for being greater than or equal to 50, and another check for being less than or equal to 100. This is the standard method for google sheet countif between two numbers.
=COUNTIFS(D:D, ">=50", D:D, "<=100")
Example (Counting Date Ranges):
This exact logic applies to counting dates, fulfilling the need for google sheet countif date range and google sheet countif between two dates. If your dates are in column E, and you want to count records submitted in January 2026:
=COUNTIFS(E:E, ">=2026-01-01", E:E, "<=2026-01-31")
When using dates, ensure they are entered in the proper standardized format (YYYY-MM-DD) or that you reference a cell containing the properly formatted date value.
Addressing Complex Scenarios in Google Sheets
While COUNTIF and COUNTIFS cover the vast majority of conditional counting needs, specialized situations require additional logical functions or advanced array manipulation.
Implementing OR Logic with COUNTIF (Using Arrays or Plus Operator)
Standard COUNTIF and COUNTIFS are built for AND logic. To count cells that meet Condition A OR Condition B, you must manually introduce the OR logic by combining the results of separate functions. This technique directly addresses how to execute a google sheets countif or condition.
The simplest way is to sum two or more COUNTIF statements using the plus (+) operator.
Example (Count if Status is “Red” OR “Blue”):
If your status values are in column E, and you want to count all records that match either color:=COUNTIF(E:E, "Red") + COUNTIF(E:E, "Blue")
Advanced OR Logic using ArrayFormula: For situations involving many OR conditions or when you want to use the output of the OR condition in further array processing, you can use ARRAYFORMULA combined with a comparison array. However, for sheer counting, the summation method above is generally cleaner and more efficient.
Counting Duplicates and Uniques
While COUNTIF alone doesn’t directly count unique occurrences across a range, it is the foundational component of the most common formula used to identify and count duplicates (count if duplicate google sheet). By applying COUNTIF within a broader formula (often coupled with ARRAYFORMULA and SUM), you can determine which items appear more than once.
To count how many unique items are present in a range (A:A):=COUNTA(UNIQUE(A:A))
To count how many times a specific item appears as a duplicate (i.e., appears more than once):
This typically involves a helper column using =COUNTIF(A:A, A2)>1 and then counting the TRUE results, or using a more complex array structure:=SUM(ARRAYFORMULA(IF(COUNTIF(A:A, A:A)>1, 1, 0)))
Counting Across Multiple Sheets (Referencing Another Sheet)
If your data is spread across different tabs within the same Google Sheet file, you can easily reference them within the COUNTIF range argument. This addresses how to countif from another sheet google sheets.
You must use the sheet name followed by an exclamation mark (!) before the range. If the sheet name contains spaces, it must be enclosed in single quotes.
Example (Another Sheet Reference):
To count all records marked “Pending” on a sheet named ‘Data Sheet’:=COUNTIF('Data Sheet'!F:F, "Pending")
For counting dynamically across different Google Sheet files, the IMPORTRANGE function is required. Since IMPORTRANGE outputs an array, it must be carefully nested within other functions (often QUERY or an ARRAYFORMULA wrapping the COUNTIF).
Advanced Criteria: Checkboxes and ArrayFormula Applications
Google Sheets treats checked boxes, a common feature for tracking completion or status, as the boolean value TRUE, and unchecked boxes as FALSE. Counting checked boxes is a straightforward COUNTIF operation:
Example (Counting Checkboxes):
To count checked boxes in column G: =COUNTIF(G:G, TRUE). This fulfills the requirement for google sheet count if box is checked.
The ARRAYFORMULA function is powerful because it allows a single formula entered in one cell to spill its results across an entire range, or to process an array of results dynamically. While standard COUNTIF generally does not require ARRAYFORMULA when returning a single numerical result, the combination (google sheets countif arrayformula) becomes necessary when:
- The
COUNTIFoutput is part of a larger, column-specific array calculation (e.g., creating a count for every row). - You are forcing
COUNTIFto work with functions that require array input, such as when usingIMPORTRANGEor complex criteria involving comparisons between two non-adjacent columns.
Troubleshooting Common COUNTIF Issues
When a COUNTIF formula returns zero, even though you visually see matching data, it’s often due to one of several common pitfalls related to syntax or data types. Understanding these nuances is crucial for reliable data reporting.
- Mismatched Text: The most common error is a space or invisible character mismatch. While
COUNTIFis case-insensitive, it is sensitive to leading or trailing spaces. If your data contains extra spaces (e.g.,"Complete "vs."Complete"), the count will fail. Use theTRIM()function on your data column to clean up these issues before counting. - Quotes around Criteria: Text criteria must be enclosed in quotes (e.g.,
"Pending"). Logical operators (>,<) combined with numbers must also be quoted (e.g.,">100"). - Concatenation Errors: When using a logical operator and referencing a cell (e.g., counting greater than the value in A1), failing to concatenate properly will result in an error or a zero count. Remember the syntax: the operator is quoted, and the cell reference is appended with an ampersand (
&):">"&A1. - Date Formatting: Dates must be provided as text strings in standard formats (e.g.,
">=2026-02-01") or referenced from a cell containing a recognized date value. If you attempt to use raw numbers that represent a date serial number without comparison operators, the count may fail.
By meticulously checking the range boundaries, ensuring consistent data formatting, and correctly applying quotation marks and concatenation rules, you can ensure your conditional counts are accurate and robust.
FAQs – Google Sheet Countif
You use the asterisk wildcard (*) within your criterion to perform partial matching. To count cells in column A that contain the word “Draft” anywhere in the text, use the formula: =COUNTIF(A:A, "*Draft*").
COUNTIF is designed to count cells based on a single criterion (one condition). COUNTIFS is designed to count cells based on multiple criteria, operating under AND logic. All conditions in COUNTIFS must be true for the cell to be counted.
Yes, you can count across multiple tabs by referencing the sheet name directly within the range argument, like =COUNTIF('Sheet 2'!A:A, "Yes"). To count across multiple entirely separate Google Sheets files, you must use the IMPORTRANGE function.
You must use the COUNTIFS function, as counting between two dates requires two separate criteria checks against the same date column. For example, to count dates between A1 and B1 in column D: =COUNTIFS(D:D, ">="&A1, D:D, "<="&B1).
This is usually caused by invisible character mismatches (like leading/trailing spaces in the data or criterion) or incorrect syntax. Ensure text criteria are quoted, and if you use logical operators with cell references, verify that you have properly used the concatenation symbol (&), like =">"&C1.