SUMIF adds up numbers in a range only when they meet a condition you set. For example, it can total all sales for a particular region, or all hours logged against one project code. To use it, you need a spreadsheet application that supports the function (Excel, Google Sheets, LibreOffice Calc) and a table with at least one column of values to add and one column to test against your condition. The function is written as =SUMIF(range, criteria, [sum_range]). The first argument is the range you check, the second is the condition, and the optional third is the range of numbers to add. If you omit the third argument, SUMIF adds the numbers in the first range itself.
What You'll Need
- A spreadsheet program such as Microsoft Excel, Google Sheets, or LibreOffice Calc.
- A table with a column of values to sum and a column of labels or numbers to test.
- Basic familiarity with cell references (e.g., A2:A100) and typing formulas.
Step-by-Step
- Identify your ranges. Decide which column holds the values you want to add (the sum range) and which column holds the condition (the criteria range). For example, column B might hold amounts and column A might hold region names.
- Click the cell where the result should appear. This is where you will type the formula. Choose an empty cell below or beside your table so the result is easy to see.
- Type the formula start. Enter
=SUMIF(including the opening parenthesis. Do not type spaces after the parenthesis. - Enter the criteria range. Select or type the range you want to test, such as
A2:A100. This range must contain the values you will compare against your condition. - Type a comma. In most locales the argument separator is a comma; some European locales use a semicolon. Use whichever your spreadsheet expects.
- Enter the criteria. This can be a number, text, a cell reference, or an expression. Text and expressions must be in double quotes, for example
"North"or">100". A cell reference such asD1does not need quotes. Wildcards?and*work in text criteria:"A*"matches any text starting with A. - Type a comma and enter the sum range. This is the range of numbers to add, such as
B2:B100. It should be the same size and shape as the criteria range. If you leave it out, SUMIF adds the numbers in the criteria range itself. - Close the parenthesis and press Enter. The formula should look like
=SUMIF(A2:A100,"North",B2:B100). The cell shows the total of all values in B2:B100 where the matching cell in A2:A100 equals "North". - Check the result. Compare it with a manual filter: filter the criteria column for the same value and look at the status bar sum of the sum column. If the numbers match, the formula is correct. If not, see Troubleshooting.
- Copy the formula if needed. Use relative references (no dollar signs) if you want the formula to adjust when copied down. Use absolute references (e.g.,
$A$2:$A$100) if the ranges should stay fixed. Press F4 after selecting a reference to toggle dollar signs.
Common Mistakes
- Mismatched range sizes. The criteria range and sum range should be the same size. If they differ, SUMIF still calculates but may use the top-left corner of the sum range and resize it to match, which can give unexpected results. Always make both ranges equal in rows and columns.
- Forgetting quotes around text or expressions. Criteria like North or >100 must be in double quotes. A cell reference does not need quotes.
- Using the wrong comparison operator. For "not equal to" use
<>, for example"<>North". For greater than or equal use>=. Operators must be inside the quotes along with the value. - Including header rows. If your criteria range includes a text header such as "Region", a criterion of "North" will not match it, but a wildcard or numeric criterion might. Keep ranges to data rows only, or use a criterion that excludes headers.
- Expecting SUMIF to handle multiple conditions. SUMIF tests only one condition. For two or more conditions, use SUMIFS, which takes multiple criteria ranges and criteria pairs.
- Text that looks like a number. Numbers stored as text will not match numeric criteria. Convert them with VALUE or by using Text to Columns.
Tips
- Use cell references for criteria so you can change the condition without editing the formula. For example, put "North" in D1 and use
D1as the criterion. - Wildcards work in text criteria:
?matches one character,*matches any sequence. To find a literal question mark or asterisk, precede it with a tilde (~?,~*). - SUMIF ignores text and empty cells in the sum range, so mixed data will not cause an error, but it also will not be added.
- For dates, use a date serial number or a function such as
DATE(2024,1,1)inside the criterion, or a text expression like">="&DATE(2024,1,1). - Named ranges make formulas easier to read: define a name for A2:A100 and use it in place of the range.
- If you need to sum with multiple conditions, switch to SUMIFS. The syntax is
=SUMIFS(sum_range, criteria_range1, criteria1, ...).
Troubleshooting
- The result is 0 when you expect a number. Check that the criteria range actually contains the value you are testing. Text may have leading or trailing spaces; use TRIM or clean the data. Also confirm the sum range contains numbers, not text.
- You get a #VALUE! error. This usually means a range reference is invalid or the criteria syntax is wrong. Check for missing quotes around text criteria and ensure ranges are valid references.
- The result is too high or too low. Verify that the criteria range and sum range line up row by row. If the sum range is offset, values from the wrong rows are added. Also check for hidden rows: SUMIF includes hidden rows unless you filter them out manually.
- Wildcards do not work. In some spreadsheet settings, wildcards are disabled. Check your program's options; in Excel, look under Advanced for "Use wildcards in formulas."
- The formula copies incorrectly. If ranges shift when you copy, use absolute references with dollar signs, or convert the data to a table so structured references adjust automatically.
- Numbers stored as text are ignored. Select the sum range, use Text to Columns or multiply by 1 in a helper column to convert text numbers to real numbers.
Frequently Asked Questions
What is the difference between SUMIF and SUMIFS?
SUMIF tests one condition. SUMIFS tests multiple conditions and uses the syntax =SUMIFS(sum_range, criteria_range1, criteria1, criteria_range2, criteria2, ...). Use SUMIFS when you need more than one criterion.
Can SUMIF use a cell reference as the criterion?
Yes. If the criterion is in cell D1, write =SUMIF(A2:A100,D1,B2:B100). Do not put quotes around the cell reference.
Does SUMIF work with dates?
Yes. Dates are stored as numbers, so you can use comparison operators. For example, =SUMIF(A2:A100,">="&DATE(2024,1,1),B2:B100) adds values where the date is on or after January 1, 2024.
Why does SUMIF return 0 for text that looks identical?
Likely causes are extra spaces, non-printing characters, or numbers stored as text. Use TRIM and CLEAN on the criteria range, and check the data type of both the criteria and sum ranges.
Can I use wildcards in SUMIF?
Yes, in most spreadsheet programs. The asterisk * matches any number of characters and the question mark ? matches one character. To match a literal wildcard, precede it with a tilde.
Is SUMIF case-sensitive?
No. SUMIF is not case-sensitive for text criteria. "North" and "north" are treated the same. For case-sensitive summing, use SUMPRODUCT with EXACT.