Table of Contents
In the dynamic environment of modern data analysis, especially when working within sophisticated spreadsheet platforms like Google Sheets, the ability to extract highly specific quantitative insights from large datasets is critically important. A frequent and essential requirement is counting the number of cells that contain a particular text fragment or string, rather than relying solely on exact matches. This capability—often referred to as “contains” matching—is invaluable for tasks such as sentiment analysis, keyword tracking across inventory descriptions, or efficiently categorizing unstructured survey responses.
This comprehensive tutorial is designed to provide expert guidance on how to leverage the powerful built-in functions, specifically COUNTIF and COUNTIFS, within Google Sheets to execute these precise “contains” matches. We will meticulously detail the methodologies for both single-criterion counting and complex multi-criteria evaluations, offering clear explanations, technical syntax, and practical, real-world examples to ensure you master these fundamental spreadsheet operations.
Understanding Wildcard Characters in Google Sheets
The core mechanism that enables “contains” searches and flexible pattern matching in Google Sheets is the strategic use of wildcard characters. These specialized symbols are placeholders that represent unknown or variable sequences of characters within your search criteria, thereby making your counting formulas exceptionally versatile and adaptable. For the specific application of identifying cells that partially match a given text, the asterisk symbol (*) serves as our primary wildcard character of choice.
The asterisk (*) possesses the crucial property of matching any sequence of characters of any length, including zero characters. When this symbol is placed immediately before and after the target string, it effectively instructs the system to search for that string regardless of what text precedes or follows it within the cell’s content. For instance, the pattern "*report*" would successfully match entries such as “Final Report Q3”, “Daily Report”, or simply “report”. Grasping this concept of flanking the search term with asterisks is the foundational step toward unlocking the full power of COUNTIF and COUNTIFS for partial matches.
This powerful feature eliminates the constraints of requiring exact matches, shifting the focus to identifying partial string occurrences. This dramatically enhances your ability to manipulate and analyze textual data within Google Sheets. Without the use of wildcard characters, achieving accurate counting based on partial text would necessitate significantly more complex, lengthy, and less efficient array formulas, making the asterisk a vital component of efficient data processing.
COUNTIF for Single Criteria “Contains” Matches
The COUNTIF function is a cornerstone of spreadsheet analysis, specifically engineered to count the number of cells within a designated range that fulfill one singular condition. When the objective is to count cells that contain a specific text string—as opposed to an exact cell-by-cell match—COUNTIF, when coupled with the asterisk wildcard character, transforms into an indispensable analytical tool. This approach is perfectly suited for straightforward scenarios where you are isolating one specific text fragment within a single column of data.
The canonical syntax required for implementing COUNTIF to execute partial text searches is defined as follows:
=COUNTIF(range, "*string*")
In this structure, the range argument identifies the collection of cells that are to be evaluated (for instance, A2:A11). Crucially, the argument "*string*" represents the search pattern incorporating the wildcard character. This pattern signals to Google Sheets that it must count every cell within the specified range that includes the designated string somewhere within its content. The asterisks enveloping the search term are essential, as they guarantee that the target string can be preceded or succeeded by any number of characters.
To provide a clear application, consider a scenario involving a dataset in Google Sheets containing a list of sports teams. Our goal is to determine how many entries in the “Team” column contain the string “Mav” (which would match names like “Mavericks” or “Mavs”). We will apply our counting formula to the sample range A2:A11. The specific formula needed to execute this partial matching task is:
=COUNTIF(A2:A11,"*Mav*")
This formula executes a scan of every cell within the defined range. Any cell that includes the substring “Mav” will be aggregated into the final count. The surrounding asterisks are mandatory, serving as wildcard characters that permit the existence of any surrounding characters, thus ensuring a true “contains” match.
The screenshot below visually confirms the accurate application and resulting output of this method:

The clear result of 5 confirms that five rows in the “Team” column successfully contain the target string “Mav” within their cell content, validating the reliability and precision of the “contains” logic when implemented with COUNTIF.
COUNTIFS for Multiple Criteria “Contains” Matches
While the COUNTIF function is superb for evaluating singular conditions, advanced and real-world data analysis often mandates the simultaneous evaluation of multiple criteria. This complex requirement is precisely where the specialized COUNTIFS function demonstrates its superior capability. COUNTIFS is designed to count cells that successfully satisfy two or more conditions across various specified ranges. By integrating this function with wildcard characters, we can execute highly sophisticated, multi-conditional “contains” searches using logical AND operations.
The standard syntax for COUNTIFS requires a structured sequence of paired arguments: a criterion range followed immediately by its corresponding criteria. This allows for the construction of intricate condition sets:
=COUNTIFS(range1, "*string1*", range2, "*string2*")
Within this powerful construction, range1 and range2 designate the respective columns or cell ranges being tested. The arguments "*string1*" and "*string2*" define the specific “contains” conditions, with each one necessarily utilizing the asterisk wildcard character for partial matching. Critically, this pattern is scalable and can be readily extended to encompass numerous range/criteria pairs, facilitating highly granular filtering and counting operations across large datasets in Google Sheets.
To demonstrate this capability, let us expand upon our prior example. Suppose the new requirement is to count players whose team name contains “Mav” AND whose position contains “Guard”. This operation necessitates checking two distinct conditions across two separate data columns. The COUNTIFS formula is ideally suited to handle this type of dual-criteria query.
For this precise, complex scenario, the resulting formula must be structured as follows:
=COUNTIFS(A2:A11, "*Mav*", B2:B11, "*Guar*")
This powerful formula specifically counts only those rows where both conditions are simultaneously met: the cell in the A2:A11 range (Team column) contains the string “Mav” AND the corresponding cell in the B2:B11 range (Position column) contains “Guar”. This mandatory “AND” logical relationship is the defining characteristic of the COUNTIFS function, enabling highly precise and intersecting data filters.
Review the accompanying screenshot for a clear, visual confirmation of this formula’s execution and the resulting output:

The visual evidence confirms that the formula successfully returns a count of 2. This result indicates that exactly two rows within our sample dataset satisfy both criteria concurrently: possessing “Mav” in the Team column and “Guar” in the Position column. This outcome effectively demonstrates the robust, multi-dimensional analytical capability inherent in the COUNTIFS function.
Common Pitfalls and Best Practices
While utilizing COUNTIF and COUNTIFS for “contains” logic in Google Sheets is highly efficient, understanding potential pitfalls and implementing rigorous best practices is paramount for ensuring accuracy. A critical factor to remember is the default handling of case sensitivity. By design, both COUNTIF and COUNTIFS are not case-sensitive; consequently, a search for “mav” will match “Mav”, “MAV”, or “Mavericks” equally. If your analysis demands strict case-sensitive matching, you must integrate these functions with advanced tools like FIND or EXACT within an ARRAYFORMULA, a method that provides superior control but significantly increases formula complexity.
Another important consideration involves the management of empty cells. It is essential to note that the wildcard character * is explicitly designed not to match blank or empty cells. If your dataset includes blanks that must be accounted for or excluded specifically, you will need to incorporate supplementary criteria or employ separate counting formulas such as COUNTBLANK or ISBLANK. Furthermore, when dealing with extraordinarily large datasets, the extensive use of wildcard character formulas may occasionally lead to performance degradation. While these functions generally perform admirably for typical datasets, optimization might be required if computation speed becomes a critical constraint.
To ensure reliable results, consistently double-check the accuracy and alignment of your specified ranges and criteria syntax. A frequently encountered error is the omission of the essential quotation marks and asterisks around the “contains” string (e.g., forgetting to use "*string*"). Additionally, when employing the COUNTIFS function for multiple conditions, always verify that the ranges designated for each criterion possess identical size and vertical alignment. Adherence to these guidelines is fundamental for producing accurate, reliable, and error-free results in all your complex counting analyses.
Conclusion
Achieving mastery over the “contains” matching functionality using COUNTIF and COUNTIFS in Google Sheets represents a significant expansion of your data analysis capabilities. By skillfully harnessing the flexibility of wildcard characters—most notably the asterisk (*)—you gain the ability to efficiently and accurately count cells based on partial text matches, whether your analysis involves a simple condition or highly intricate, multi-layered criteria.
These specialized formulas offer a robust and automated solution for extracting precise, actionable information from your spreadsheets, enabling you to derive deeper insights without resorting to manual filtering or time-consuming sorting procedures. The utility of this partial matching technique is broad and invaluable: from rapidly identifying specific keywords within customer feedback comments to systematically categorizing complex entries based on partial identifying strings.
We strongly recommend actively practicing these techniques using your own professional datasets. Experimentation with various strings and multiple combined conditions will solidify your understanding and allow you to fully appreciate the remarkable flexibility and analytical power that these native COUNTIF and COUNTIFS functions provide.
Additional Resources
To further advance your technical proficiency in Google Sheets, we encourage you to explore these related tutorials that cover other essential functions and data manipulation operations:
Cite this article
Mohammed looti (2025). Use COUNTIF Contains in Google Sheets. PSYCHOLOGICAL STATISTICS. Retrieved from https://statistics.arabpsychology.com/use-countif-contains-in-google-sheets/
Mohammed looti. "Use COUNTIF Contains in Google Sheets." PSYCHOLOGICAL STATISTICS, 27 Oct. 2025, https://statistics.arabpsychology.com/use-countif-contains-in-google-sheets/.
Mohammed looti. "Use COUNTIF Contains in Google Sheets." PSYCHOLOGICAL STATISTICS, 2025. https://statistics.arabpsychology.com/use-countif-contains-in-google-sheets/.
Mohammed looti (2025) 'Use COUNTIF Contains in Google Sheets', PSYCHOLOGICAL STATISTICS. Available at: https://statistics.arabpsychology.com/use-countif-contains-in-google-sheets/.
[1] Mohammed looti, "Use COUNTIF Contains in Google Sheets," PSYCHOLOGICAL STATISTICS, vol. X, no. Y, ص Z-Z, October, 2025.
Mohammed looti. Use COUNTIF Contains in Google Sheets. PSYCHOLOGICAL STATISTICS. 2025;vol(issue):pages.