Google Sheets SUMIF Wildcards: Match Text or a Literal Asterisk
A product code containing an asterisk can accidentally match many more products than intended. The same SUMIF syntax that is useful for a starts-with report needs an escape when the star is part of the actual code.
Separate pattern matching from literal code matching
Put sumif-patterns-input.csv in A1:B8 in desktop Google Sheets. Every code is text and every amount is numeric. The code SKU* genuinely contains a star; it is not a placeholder in the input. Keep the complete fixture, because the similar-looking codes are what expose an overbroad criterion.
The intended report determines whether the star is a wildcard. A manager asking for the whole SKU family wants 220. A reconciliation asking for the specific code printed as SKU* wants 10. Both requests are reasonable, and the same visible characters in a criterion cell can produce very different results unless the distinction is explicit.
Start with the three wildcard meanings
An asterisk matches zero or more characters, so SKU* includes the plain code SKU as well as its longer variants. A question mark stands for one character, so SKU-? matches SKU-A but not SKU-AB. The tilde is the escape prefix used when a wildcard character should be treated literally.
Enter the three formulas below in separate summary cells. They must return 220, 30 and 70. The last result is a useful control: the exact text SKU is a real record, and the asterisk pattern includes that record because zero extra characters are allowed. Do not mistake starts-with for starts-with-and-has-a-suffix.
Starts with SKU: =SUMIF(A2:A8,"SKU*",B2:B8)
Exactly one character after SKU-: =SUMIF(A2:A8,"SKU-?",B2:B8)
Exact SKU: =SUMIF(A2:A8,"SKU",B2:B8)Escape literal stars and question marks; check tildes separately
Use ~* for a literal star and ~? for a literal question mark. The criterion still needs quotes when written directly in a formula. SKU~* totals 10 and SKU~? totals 20 in the worked Sheet. To find a literal star anywhere, combine a wildcard, an escaped star and a final wildcard: *~** also totals 10.
Google’s SUMIF documentation describes ~~ as the escape for a literal tilde. In our actual browser Sheet on October 5, 2026, however, SUMIF(A2:A8,"SKU~~",B2:B8) returned 0, while the plain "SKU~" criterion returned 50. That is an observed result for this fixture, not a promise about every workbook or a diagnosed product defect. The downloadable expected-pattern file therefore covers the verified star/question-mark cases. Use the equality method below for a literal punctuation-bearing code.
Literal SKU*: =SUMIF(A2:A8,"SKU~*",B2:B8)
Literal SKU?: =SUMIF(A2:A8,"SKU~?",B2:B8)
Contains a literal star: =SUMIF(A2:A8,"*~**",B2:B8)Match a product-code cell with equality instead of wildcard criteria
Enter the exact requested product code in E2 and put the formula below in F2. This compares each source code with E2 directly; punctuation is part of the value, not a SUMIF pattern. SKU*, SKU? and SKU~ return 10, 20 and 50 respectively, and SKU-A returns 30.
This example requires numeric, error-free amounts in B2:B8 and the same row bounds in both ranges. Check them with ISNUMBER before calculating. Use bounded ranges rather than whole columns. Equality is case-insensitive here; this formula does not promise a case-sensitive code lookup. It also sums every matching occurrence, so duplicate source codes need an explicit business policy rather than automatic removal.
=SUMPRODUCT(($A$2:$A$8=E2)*$B$2:$B$8)Keep numeric totals separate from matching text
Check =ISNUMBER(B2) down the amount column. A code matching the criterion does not guarantee that its amount is usable numeric data. Preserve negative adjustments if they belong in the report; dropping a refund can make a technically correct pattern produce a misleading business total.
Use text wildcards for text labels, not for month numbers displayed by formatted date cells. Dates can be stored numerically even when they look like text. A request such as January sales needs date boundaries with a year, not an assumption that a date's printed 01 prefix is searchable text. The existing date guides cover that separate workflow.
As a separate acceptance exercise, append SKU* with -3 and SKU* with 0 below the sample and extend both ranges to row 10. The SKU* wildcard total becomes 217; literal SKU* equality becomes 7. Both added occurrences count, and the refund is retained. These two outcomes were calculated in the worked browser Sheet; keep the original A2:B8 bounds when reproducing the baseline downloads.
Verify matched records, not only the final sum
For SKU-?, inspect the source and confirm that SKU-A is included and SKU-AB is excluded. For SKU*, confirm that OTHER is the only omitted row. For the literal star criterion, inspect the actual code cell rather than relying on a description such as star product that may hide its punctuation.
The fixture has positive, distinct amounts to make failures easy to see. In a real export, wrongly included positive and negative rows can cancel out and leave the same total. Keep a record-level sample with a known expected match set when changing criteria. A total is a useful reconciliation, but it is not a substitute for checking which rows were selected.
Choose a different tool when the requirement changes
SUMIF provides one matching criterion. A report that also requires a specific region, status or date interval needs a deliberately constructed multi-condition calculation. Do not concatenate unrelated business fields into the product code merely to fit everything into a single wildcard.
The examples use English function names and comma separators in Google Sheets. SUMIF wildcards are not regular expressions: a dot or bracket does not acquire regex meaning. The worked formulas were entered and calculated in an actual browser Sheet on October 5, 2026, including the six supported pattern totals and the four literal-code equality totals. Check the source types and matched records again when adapting the example.
Common questions
Why does SKU* total much more than the SKU* row?
The star is a wildcard in the criterion. Use SKU~* when the star is part of the literal code.
How do I match a tilde itself?
Google documents ~~ as the literal-tilde escape, but it returned 0 for SKU~ in our worked Sheet while equality returned the intended 50. For this product-code task, use the supplied SUMPRODUCT equality formula and verify its matched rows.
Can I use January wildcard text on real dates?
Do not infer text content from a date display. Use actual date boundaries for a dated report, including the year.
Sources & method
- Google Docs Editors Help: SUMIF ↗
- Google Docs Editors Help: SUBSTITUTE ↗
- Google Docs Editors Help: ISNUMBER ↗
- Google Docs Editors Help: SUMIFS ↗
- Google Docs Editors Help: SUMPRODUCT ↗
Examples and diagrams use synthetic data. Application instructions follow the linked documentation; available menus and options can vary. Our sample checks do not establish behavior in every Excel or Google Sheets version. Read our AI-assisted editorial method.