4/25/2025

how to sum with condition in google sheets

IN SUMMARY

The SUMIF function in Google Sheets allows you to sum values based on a specified condition. It's a powerful tool for selectively summing data that meets certain criteria.

Using the SUMIF Function

The syntax for the SUMIF function is: =SUMIF(range, criteria, [sum_range]). The range is the range of cells to evaluate against the criteria. The criteria is the condition that cells must meet to be included in the sum. The optional sum_range is the range of cells to sum if the corresponding cells in the range meet the criteria.

Let's say you have a list of sales figures in column B, and the corresponding product names in column A. To sum the sales for a specific product, say 'Widget', you would use: =SUMIF(A2:A10, "Widget", B2:B10). This sums the values in column B where the corresponding cell in column A contains 'Widget'.

You can use wildcards like * and ? in the criteria to match patterns. You can also use operators like >, <, >=, <=, and <> to sum values based on numeric conditions. For example, =SUMIF(B2:B10, ">100", B2:B10) sums the values in column B that are greater than 100.

Advanced SUMIF Techniques

The SUMIFS function allows you to apply multiple criteria across different ranges. For example, =SUMIFS(C2:C10, A2:A10, "Widget", B2:B10, ">100") sums the values in column C where column A contains 'Widget' and column B is greater than 100.

You can use array formulas to sum values based on multiple criteria within the same range. For example, =SUM(IF((A2:A10="Widget")*(B2:B10>100), C2:C10)) sums the values in column C where column A contains 'Widget' and column B is greater than 100, all within the same range.

You can combine SUMIF with other functions like COUNTIF, AVERAGEIF, and MAXIF to perform various conditional calculations. For example, =AVERAGEIF(A2:A10, "Widget", B2:B10) calculates the average of values in column B where column A contains 'Widget'.

Tips and Best Practices

When copying formulas, use absolute references ($A$1) for ranges that should remain fixed, and relative references (A1) for ranges that should adjust based on the new location.

Instead of typing out long range references, you can create named ranges for easier readability and maintenance. This is especially useful for complex formulas or frequently used ranges.

Be mindful of potential errors, such as #VALUE! (caused by incorrect data types) or #DIV/0! (caused by division by zero). Use error handling functions like IFERROR or IFNA to gracefully handle these situations.

Want to automate your busy work in Google Sheets with AI?

Videos