Consolidating fragmented data when descriptions or codes do not match exactly is a persistent headache for analysts. While standard exact-match formulas and manual sorting are traditional fallback methods, they quickly fail at scale. Utilizing wildcard characters grants analysts the immediate ability to dynamically aggregate diverse datasets without tedious data cleaning. Keep in mind the critical stipulation: wildcards only work with text criteria, not raw numeric values. For example, pairing SUMIFS with "North*" easily captures both "Northwest" and "Northeast" revenues. Below, we will detail the exact formulas needed to master wildcard summation in your spreadsheets.
Excel is an incredibly powerful tool for data analysis, but real-world data is rarely perfect. You will often find yourself needing to aggregate values based on criteria that are incomplete, inconsistent, or only partially known. For instance, you might want to sum sales for all products that contain the word "Pro", calculate expenses for all departments starting with "Mktg", or aggregate accounts with a specific regional code prefix.
In these situations, standard exact-match lookups fall short. This is where wildcard characters come to the rescue. By combining Excel's summing functions-such as SUMIF, SUMIFS, and SUMPRODUCT-with wildcards, you can build dynamic, flexible formulas that match patterns rather than literal text.
In this comprehensive guide, we will explore how to construct Excel formulas to sum data using wildcard match criteria, covering basic to advanced techniques, cell references, and troubleshooting common pitfalls.
Before diving into formulas, it is essential to understand the three wildcard characters that Excel recognizes in text searches:
*): Represents any sequence of characters, including zero characters. For example, "East*" will match "East", "Eastern", and "East-Region".?): Represents any single character. For example, "Te?t" will match "Test", "Text", or "Tent", but not "Teest".~): Acts as an escape character. If you need to search for an actual asterisk, question mark, or tilde in your data, place a tilde before it (e.g., "~*" to search for a literal asterisk).Note: Wildcard characters only work with text data. If your criteria range consists of pure numeric values (like dates or currency), wildcards will not match them directly without converting them to text first.
To illustrate these concepts, we will use the following sample data table representing product sales across different regions and categories:
| Product Code (Col A) | Product Name (Col B) | Region (Col C) | Sales (Col D) |
|---|---|---|---|
| APP-101 | Apple iPhone 14 | North-East | $1,200 |
| APP-102 | Apple iPad Pro | North-West | $850 |
| SAM-201 | Samsung Galaxy S23 | South-East | $1,100 |
| SAM-202 | Samsung Galaxy Tab | South-West | $600 |
| APP-103 | Apple Watch Series 8 | North-East | $400 |
| ACC-301 | USB-C Charger *Promo* | National | $150 |
*) WildcardThe asterisk is the most frequently used wildcard because it allows you to perform "begins with", "ends with", and "contains" matches.
To sum sales for all products where the product code starts with "APP" (Apple products), you place the asterisk at the end of your criteria string:
=SUMIF(A2:A7, "APP*", D2:D7)
How it works: Excel looks at the range A2:A7 and identifies every cell that starts with "APP", regardless of what follows. It then sums the corresponding values in D2:D7 ($1,200 + $850 + $400 = $2,450).
If you want to sum sales for any product name containing the word "Galaxy", wrap the word in asterisks:
=SUMIF(B2:B7, "*Galaxy*", D2:D7)
How it works: The wildcards on both sides ensure that "Galaxy" will match whether it appears at the beginning, middle, or end of the text. This sums the Samsung Galaxy S23 ($1,100) and the Samsung Galaxy Tab ($600) to return $1,700.
To sum sales for regions that end with the word "East", place the asterisk at the beginning of your criteria:
=SUMIF(C2:C7, "*East", D2:D7)
How it works: This matches "North-East" and "South-East", summing $1,200 + $1,100 + $400 = $2,700.
?) WildcardThe question mark wildcard is perfect when you know the exact length of the string or have strict structural pattern variations.
Assume your product codes follow a strict format where the third character of the prefix determines a sub-batch, e.g., AP?-101. If you want to match "APP-101", "APS-101", or "APX-101" but exclude "APPP-101", you can write:
=SUMIF(A2:A7, "AP?-101", D2:D7)
This matches any string starting with "AP", followed by any single character, followed by "-101".
Hardcoding your search criteria directly into the formula (e.g., "APP*") makes your workbook rigid. In professional environments, it is better practice to reference a cell containing the criteria. To do this, you must use the concatenation operator (&).
Suppose cell F2 contains the text search value: Apple. To sum all sales where the product name contains the value in F2, write your formula like this:
=SUMIF(B2:B7, "*" & F2 & "*", D2:D7)
Crucial Rule: The wildcard characters must be wrapped in double quotes ("*"), while the cell reference (F2) remains outside the quotes, joined together by the ampersand (&).
When you have multiple partial-match conditions, transition from SUMIF to SUMIFS. Note that the syntax order changes: SUMIFS puts the sum range first, followed by criteria range and criteria pairs.
Let's say you want to sum sales where the Product Name contains "Apple" AND the Region starts with "North":
=SUMIFS(D2:D7, B2:B7, "*Apple*", C2:C7, "North*")
Calculation:
In our sample data, Row 7 contains the product name "USB-C Charger *Promo*". If you want to sum sales specifically for products containing a literal asterisk (*), a standard search for "*Text*" won't behave as expected because Excel treats the asterisk as a wildcard.
To tell Excel to search for a literal asterisk, prepend it with a tilde (~):
=SUMIF(B2:B7, "*~*Promo~", D2:D7)
Here, the outer asterisks act as wildcards, while ~* tells Excel to look for the physical symbol * surrounding "Promo". This correctly returns $150.
By default, SUMIF and SUMIFS are completely case-insensitive. Searching for "*apple*" will yield the exact same results as searching for "*APPLE*".
If you need to perform a case-sensitive partial-match sum, you must combine SUMPRODUCT with the case-sensitive FIND function, which natively returns the starting character position of a substring (or an error if not found):
=SUMPRODUCT(--(ISNUMBER(FIND("Apple", B2:B7))), D2:D7)
FIND("Apple", B2:B7) searches for the exact case-sensitive string "Apple" inside each cell of the range. It returns a number if found (e.g., 1 or 7) or a #VALUE! error if not.ISNUMBER(...) converts those numbers to TRUE and errors to FALSE.--) coerces the TRUE and FALSE values into 1 and 0.SUMPRODUCT multiplies this binary array by the sales array (D2:D7) and sums the result, effectively giving you a case-sensitive wildcard sum.10100 with "101*"). To fix this, convert the numerical column to Text formatting, or use helper columns."*" & A1 & "*" is correct; "*A1*" is incorrect.SUMIFS, make sure all criteria ranges are of the exact same size and orientation as your sum range, otherwise, Excel will return a #VALUE! error.By mastering wildcard parameters with SUMIF, SUMIFS, and SUMPRODUCT, you can drastically reduce the amount of pre-cleaning required on your datasets, making your Excel models both more robust and easier to maintain.
Disclaimer:
The documents and templates provided on this page are for informational and illustrative purposes only. They do not constitute professional, legal, or financial advice, and should not be relied upon as such. Because individual circumstances and regulatory requirements vary, these materials may not be suitable for your specific needs. We recommend consulting with a qualified professional before adapting or using any of these examples for official or commercial purposes.