Google Sheets SUMIF Like: Wildcard and Partial Match Guide
In this article
To sum values in Google Sheets where a text column contains a specific word or pattern, use SUMIF with wildcards: =SUMIF(range, "*text*", sum_range). The asterisks tell Sheets to match any characters before and after your text, so "*apple*" catches "apple", "pineapple", and "apple pie". This guide walks through the exact syntax, the wildcard rules, and the fixes when your formula returns zero or the wrong total.
What You'll Need
- A Google account with access to Google Sheets (the web version at sheets.google.com or the mobile app).
- A spreadsheet with at least one column of text labels and one column of numbers to sum.
- Basic familiarity with cell references like A2:A100 and B2:B100.
Step-by-Step
- Open your spreadsheet and identify the two ranges. The range is the column you want to search (for example, A2:A100 containing product names). The sum_range is the column of numbers to add (for example, B2:B100 containing sales amounts). Both ranges must be the same size and start on the same row.
- Click an empty cell where you want the result to appear.
- Type the SUMIF formula with wildcards. The pattern is
=SUMIF(range, "*text*", sum_range). For example, to sum all sales where the product name contains "apple", enter=SUMIF(A2:A100, "*apple*", B2:B100). - Press Enter. The cell now shows the total of all matching rows. The asterisks around the word are what make it a "like" match rather than an exact match.
- Adjust for case sensitivity if needed. SUMIF is not case-sensitive by default, so "*apple*" matches "Apple" and "APPLE". If you need case-sensitive matching, you must use SUMPRODUCT with FIND or EXACT instead, because SUMIF has no case-sensitive switch.
- Use a cell reference for the search term to make the formula flexible. Put the word "apple" in D1, then write
=SUMIF(A2:A100, "*"&D1&"*", B2:B100). Changing D1 updates the total without editing the formula. - Test with a small range first. Select just a few rows (like A2:A10 and B2:B10) and compare the SUMIF result to a manual sum of the matching rows. Once it matches, expand to the full range.
- Copy the formula down or across if you are building a summary table. Use absolute references (like $A$2:$A$100) for the ranges so they do not shift when you copy.
Common Mistakes
- Forgetting the asterisks.
SUMIF(A2:A100, "apple", B2:B100)only matches cells that are exactly "apple", not "apple pie" or "pineapple". - Mismatched range sizes. If the range is A2:A100 and the sum_range is B2:B99, Sheets may return an error or an incorrect total. Both ranges must have the same number of rows.
- Using the wrong wildcard character. In Google Sheets, the wildcard is the asterisk (*) and the question mark (?) for a single character. Some locales use different settings, but the default is asterisk.
- Including the header row. If your range starts at row 1 and includes a text header like "Product", the wildcard may match it if the header contains the search word. Start ranges at row 2.
- Expecting case-sensitive results. SUMIF ignores case. If you need to distinguish "Apple" from "apple", use a different function.
- Quoting errors. The criteria must be a text string in quotes, or a cell reference concatenated with wildcards. Mixing quotes and references incorrectly (like
"*"D1"*") causes a formula parse error.
Tips
- Use question marks for single-character wildcards. "?apple" matches "5apple" but not "55apple".
- Escape literal asterisks or question marks with a tilde (~). To match a cell that literally contains "a*b", use "a~*b".
- Combine with other criteria using SUMIFS for multiple conditions, for example
=SUMIFS(B2:B100, A2:A100, "*apple*", C2:C100, ">100"). - Use named ranges to make formulas easier to read: select A2:A100, go to Data > Named ranges, and name it ProductNames. Then write
=SUMIF(ProductNames, "*apple*", Sales). - Check for leading or trailing spaces in your text column. A cell containing "apple " (with a space) still matches "*apple*", but a cell containing " apple" also matches. If you need exact word boundaries, use a more specific pattern like "* apple *" or trim your data first.
Troubleshooting
If your SUMIF returns 0 when you expect a total, check these in order:
- Verify the ranges are correct. Click the formula cell and look at the highlighted ranges on the sheet. Make sure the sum_range aligns with the range row by row.
- Confirm the wildcard is present. The criteria should be "*text*" (with quotes). If you used a cell reference, ensure it is concatenated with & and asterisks.
- Check for hidden characters. Use
=LEN(A2)to see if a cell has extra spaces or non-printing characters. Clean with TRIM or CLEAN if needed. - Look for numbers stored as text. If the sum_range contains numbers formatted as text (often left-aligned), SUMIF may ignore them. Convert with VALUE or multiply by 1.
- Test with a simpler formula. Try
=SUMIF(A2:A100, "*a*", B2:B100)to see if any matches occur. If that works, your original search term may have a typo. - Check for errors in the range. If any cell in the sum_range contains an error like #N/A, the SUMIF may return an error. Use IFERROR or clean the data.
If the formula still does not work, try rebuilding it in a new cell from scratch, and compare with a manual filter: apply a filter to the text column (Data > Create a filter), choose "Text contains" and your word, then select the visible numbers and read the sum in the status bar. That manual total should match your SUMIF result.
Frequently Asked Questions
Can SUMIF match partial text in Google Sheets?
Yes. Use asterisks around the text: =SUMIF(A2:A100, "*text*", B2:B100). This sums rows where the cell contains "text" anywhere.
Is SUMIF case-sensitive?
No. SUMIF treats "Apple" and "apple" the same. For case-sensitive partial matches, use SUMPRODUCT with FIND or EXACT.
How do I sum cells that start with a specific word?
Use a trailing asterisk only: =SUMIF(A2:A100, "apple*", B2:B100). This matches cells beginning with "apple".
Can I use wildcards with cell references in SUMIF?
Yes. Concatenate the reference with asterisks: =SUMIF(A2:A100, "*"&D1&"*", B2:B100).
Why does my SUMIF return 0 even though I see matching text?
Common causes: missing asterisks, mismatched range sizes, numbers stored as text, or extra spaces in the text column. Check each of these.
Does SUMIF work in the Google Sheets mobile app?
Yes, the formula works the same way in the Android and iOS apps. You can type it manually or use the function list.