Excel SUMIF Function
The Excel SUMIF function returns the sum of cells that meet a single condition. Criteria can be applied to dates, numbers, and text. The SUMIF function supports logical operators (>,<,<>,=) and wildcards (*,?) for partial matching.
- range - The range of cells that you want to apply the criteria against.
- criteria - The criteria used to determine which cells to add.
- sum_range - [optional] The cells to add together. If sum_range is omitted, the cells in range are added together instead.
The SUMIF function returns the sum of cells in a range that meet a single condition. The first argument is the range to apply criteria to, the second argument is the actual criteria, and the last argument is the range containing values to sum. SUMIF supports logical operators (>,<,<>,=) and wildcards (*,?) for partial matching. Criteria can use a value from another cell, as explained below.
SUMIF is in a group of eight functions in Excel that split logical criteria into two parts (range + criteria). As a result, the syntax used to construct criteria is different, and SUMIF requires a cell range for the range argument, you can't use an array.
SUMIF only supports a single condition. If you need to apply multiple criteria, use the SUMIFS function. If you need to manipulate values that appear in the range argument (i.e. extract the year from dates to use in criteria) see the SUMPRODUCT and/or FILTER functions.
Example #1 - basic usage
In the worksheet shown, there are three SUMIF examples. In the first example (G6), SUMIF is configured to sum values greater than 100. In the second example (G7), SUMIF returns the sum of values where the color is "red". In the last example (G8), SUMIF is configured to sum values where the state is "CA" (California).
Notice the equals sign (=) is not required when constructing "is equal to" criteria. Also notice SUMIF is not case-sensitive. You can sum values where the Rep is Jim using "jim" or "Jim".
Example #2 - criteria from another cell
A value from another cell can be included in criteria using concatenation. In the example below, SUMIF will return the sum all sales over the value in G4. Notice the greater than operator (>), which is text, must be enclosed in quotes. The formula in G5 is:
=SUMIF(D5:D9,">"&G4) // sum if greater than G4
Example #3 - SUMIF not equal to
To express "not equal to" criteria, use the "<>" operator surrounded by double quotes (""):
Again notice SUMIF is not case-sensitive.
Example #4 - SUMIF with dates
Notice we must concatenate an operator to the date in E9. To use more advanced date criteria (i.e. all dates in a given month, or all dates between two dates) you'll want to switch to the SUMIFS function, which can handle multiple criteria.
Example #5 - SUMIF with wildcards
The SUMIF function supports wildcards, as seen in the example below:
See below for more SUMIF formula examples.
- SUMIF only supports one condition. Use the SUMIFS function for multiple criteria.
- When sum_range is omitted, the cells in range will be summed.
- Text strings in criteria must be enclosed in double quotes (""), i.e. "apple", ">32", "ja*"
- Cell references in criteria are not enclosed in quotes, i.e. "<"&A1
- The wildcard characters ? and * can be used in criteria. A question mark matches any one character and an asterisk matches any sequence of characters (zero or more).
- To find a literal question mark or asterisk, use a tilde (~) in front question mark or asterisk (i.e. ~?, ~*).
- SUMIFS requires a range, you can't substitute an array.