Smart Systems for Home

Plain how-to guides for smart home, security and home Wi-Fi

Google Sheets SUMIF: Sum Cells Containing Specific Text

· 5 min read · Home Tech

In this article
  1. What You'll Need
  2. Step-by-Step
  3. Common Mistakes
  4. Tips
  5. Troubleshooting
  6. Frequently Asked Questions

Yes, you can sum values based on text criteria in Google Sheets using the `SUMIF` function. This formula allows you to add up numbers in a range only if corresponding cells in another range contain specific text, such as "Completed" or "Pending." It is essential for creating dynamic reports where totals change based on categorical data rather than just numerical thresholds.

What You'll Need

  • A Google Sheets document with at least two columns of data.
  • A Criteria Range: The column containing the text labels (e.g., Status, Category).
  • A Sum Range: The column containing the numeric values you want to add up.
  • The specific text string you want to match (e.g., "Shipped").

Step-by-Step

  1. Identify your data ranges. Locate the column with the text labels and the column with the numbers. For example, assume Column A contains status text like "Paid" or "Unpaid," and Column B contains dollar amounts.
  2. Select the output cell. Click on an empty cell where you want the total sum to appear.
  3. Start the SUMIF function. Type `=SUMIF(` into the selected cell.
  4. Define the Criteria Range. Select the range of cells that contain the text you are checking against. For instance, if your statuses are in A2:A100, type `A2:A100`. Add a comma after this selection.
  5. Enter the Criterion. Specify the text you want to match. If you are looking for the exact word "Paid," type `"Paid"` including the quotation marks. If you want to use a value from another cell (like D1) as the criterion, simply select cell D1 without quotes. Add a comma after this entry.
  6. Define the Sum Range. Select the range of cells that contain the numbers you want to add. If your amounts are in B2:B100, type `B2:B100`.
  7. Close the parenthesis and execute. Type `)` and press Enter. The cell will now display the sum of all values in Column B where the corresponding cell in Column A says "Paid."

Common Mistakes

One frequent error is mismatching the size of the Criteria Range and the Sum Range. While Google Sheets is flexible, ensuring both ranges have the same number of rows prevents unexpected results. Another common issue is forgetting quotation marks around static text criteria. Writing `=SUMIF(A2:A10, Paid, B2:B10)` will result in an error because "Paid" is interpreted as a named range or variable, not a text string. Always use `"Paid"` unless referencing a cell.

Case sensitivity is also a point of confusion. By default, `SUMIF` is case-insensitive, meaning it treats "paid," "PAID," and "Paid" as identical. However, if you need strict case matching, `SUMIF` alone cannot do this; you would need to combine it with other functions like `EXACT`, which complicates the formula significantly. Most users find the default case-insensitivity helpful, but be aware of it if your data relies on capitalization for distinction.

Tips

Use wildcards to make your formulas more robust. If you want to sum all items that start with a certain letter or contain a substring, you can use the asterisk (`*`) wildcard. For example, `=SUMIF(A2:A100, "App*", B2:B100)` sums values where the text starts with "App," capturing "Apple," "Application," and "Appetizer." The question mark (`?`) wildcard represents any single character, useful for patterns like "C?t" to match "Cat" or "Cut."

Lock your ranges when copying formulas. If you plan to drag this formula down to calculate sums for different categories listed in a separate column, use absolute references for the data ranges. Change `A2:A100` to `$A$2:$A$100` and `B2:B100` to `$B$2:$B$100`. This ensures that when you copy the formula to new rows, the source data doesn't shift incorrectly. You can quickly toggle these locks by pressing F4 (or Cmd+Shift+L on Mac) while editing the formula.

Troubleshooting

If your result is zero or incorrect, first check for hidden spaces in your text data. A cell might look like it contains "Paid," but actually holds "Paid " (with a trailing space). These spaces prevent exact matches. To fix this, you can wrap your criteria in a `TRIM` function within the formula structure, though `SUMIF` itself doesn't support `TRIM` directly on the range argument easily. A better approach is to clean your source data using `=TRIM(A2)` in a helper column or use Find & Replace to remove extra spaces.

Ensure there are no formatting issues with your numbers. If the Sum Range contains text-formatted numbers (often indicated by a green triangle in the corner), they will not be added. Convert these to actual numbers by selecting the range, clicking the three-dot menu that appears next to the warning icon, and choosing "Convert to number." Also, verify that your criterion exactly matches the spelling in the data range. Typos in the search term will yield a sum of zero.

Frequently Asked Questions

Can I sum based on multiple text conditions?

No, `SUMIF` only handles one condition. If you need to sum based on multiple criteria (e.g., Status is "Paid" AND Region is "North"), you must use the `SUMIFS` function instead. The syntax is similar, but you list each criteria range followed by its respective criterion.

Does SUMIF work with dates?

Yes, but you must format them correctly. Dates in Google Sheets are stored as serial numbers. You can use comparison operators like `<` or `>` with date strings or cell references. For example, `=SUMIF(DateRange, "<"&TODAY(), AmountRange)` sums amounts for past dates.

How do I sum if a cell contains part of a text?

Use the wildcard method mentioned in the Tips section. Place the asterisk before and after the text fragment you are searching for. For example, to sum anything containing the word "test," use `"*test*"` as your criterion.

Why is my SUMIF returning #VALUE!?

This usually happens if the Sum Range contains errors or non-numeric text that cannot be coerced into a number. Check the cells in your Sum Range for error codes like `#N/A` or `#REF!`. You may need to filter out errors or use `SUMPRODUCT` with `ISNUMBER` checks for more complex scenarios.

Can I reference another sheet?

Yes, you can reference ranges from other sheets within the same spreadsheet. Simply click on the tab of the other sheet while building the formula, then select the range. The reference will automatically update to include the sheet name, such as `'Sheet2'!A2:A100`.