Knowledge base / Excel

SUMIF in Excel: one criterion and the correct range

Four entries explain quantity totals, cell criteria and wildcards. I also show why an apparently correct answer does not establish that the range references are right.

Kajo RudzińskiPublished Updated 5 min read

A single gate selects matching shapes and their associated blocks.

SUMIF adds values from rows matching one criterion. I read it as two connected steps: first check the category or number, then add the value from the corresponding cell. The range being checked and the range being summed need not be the same column.

I use one small table in both languages to explain text, a threshold from a cell, a wildcard and the range-size trap. The records are synthetic and the values represent units. The answer is therefore a quantity total, rather than a count of rows.

Syntax and language

Microsoft documents SUMIF, called SUMA.JEŻELI in Polish, for Microsoft 365 and Excel 2016, 2019, 2021 and 2024, among other editions.

=SUMIF(range,criteria,[sum_range])

range is evaluated, criteria specifies the match, and sum_range supplies numbers to add. If the last argument is omitted, the function sums the range being evaluated. Square brackets in the description mean optional; do not include them in an actual formula.

I use commas in these English examples. Regional settings affect the argument separator, so your environment may differ. Check the language of function names separately.

One table for every example

Place headers in A1:B1 and these four records in A2:B5. Product labels are deliberately identical in the Polish and English versions, allowing comparisons without translating cell contents.

Row A: Product B: Units
2 Atlas 10
3 Boreal 20
4 Atlas 5
5 Atlas Pro 15

The first question is how many units belong to the product named Atlas:

=SUMIF(A2:A5,"Atlas",B2:B5)

Rows 2 and 4 match. Adding 10 and 5 gives 15. Atlas Pro does not match this criterion. Two records contribute, but the function returns the sum of their units rather than the number of records.

Read a criterion from a cell

Enter Atlas in D2 and use:

=SUMIF(A2:A5,D2,B2:B5)

The result remains 15. Changing D2 to Boreal produces 20. I do not put D2 in quotation marks because I want its contents. Writing "D2" would create a text criterion, searching for that label in column A.

I would place a Product label beside D2 so the reader understands what the cell controls. A separate parameter makes selection easier, but does not establish that the name is valid. Look for additional spaces in the records and confirm that the selected category actually exists.

A numeric threshold and operator

Now sum the values in B2:B5 that are greater than 10:

=SUMIF(B2:B5,">10")

The result is 35, from 20 and 15. The value 10 is excluded because > does not include equality. Using ">=10" would include 10, 20 and 15, producing 45.

If D3 contains the threshold 10, use:

=SUMIF(B2:B5,">"&D3)

The operator is quoted text, and & joins it to the cell’s contents. This lets you change the threshold without rewriting the formula. Writing ">D3" would not read the number stored in D3.

A single gate selects matching shapes, whose blocks enter a shared collection tray.

A wildcard broadens the match

Microsoft documents the wildcard characters: an asterisk matches any sequence of characters and a question mark matches one character. For example:

=SUMIF(A2:A5,"Atlas*",B2:B5)

This now matches Atlas and Atlas Pro. The result is 30, from 10, 5 and 15. It answers a different question from the total for Atlas alone. I do not add an asterisk merely to force a result when an exact criterion is failing.

To match a literal asterisk, put a tilde before it: ~*. Similarly, ~? matches a literal question mark. The pattern applies to text and should represent the intended rule for selecting a product.

Different range sizes can fail quietly

The important trap is that SUMIF’s sum_range is not an absolute end boundary. Microsoft explains that when its dimensions differ, the function starts at the first cell in that argument and uses the dimensions of the range being evaluated.

=SUMIF(A2:A5,"Atlas",B2:B3)

I avoid this construction. The final argument appears to contain two rows, but the evaluated range contains four. The effective sum range therefore starts at B2 and extends for four rows. Our table may still produce 15. An apparently correct answer does not establish that the references clearly describe the intended selection.

Use matching boundaries, here A2:A5 and B2:B5. SUMIFS requires ranges with the same number of rows and columns. Do not automatically transfer one function’s range behaviour to the other.

Zero needs interpretation

If D2 contains a product absent from the table, the total is zero. Zero alone cannot explain whether no records matched or matching quantities added to zero. Both are possible in data with adjustments. When a result is surprising, inspect the matching records rather than treating the number as a complete diagnosis.

For counting records with one criterion, read COUNTIF. For adding all numbers without a condition, use SUM. First name the expected unit: records or quantities.

A short exercise

Change the criterion from Atlas to Atlas Pro, then Atlas*. Identify the expected contributing rows before reading the result. Next set the numeric threshold to 20 and compare > with >=. In the original table, the first returns zero and the second returns 20.

Finally, check the references and content types in column B. A product name can match while its quantity remains text after import. Avoid hiding a discrepancy with a random wildcard or arbitrary threshold. Establish whether the issue concerns matching, cell contents or the definition of the question.

Key takeaways

Does SUMIF count matching rows?

It adds numbers from matching records rather than returning their count. Two matching rows containing quantities 10 and 5 produce 15; COUNTIF counts records.

Does a shorter sum_range always produce an error?

No. Excel can start at its first cell and use the evaluated range's dimensions. Explicitly supply matching boundaries for the two ranges.

How do I combine an operator with a cell threshold?

Quote the operator and join it to the cell reference using &, for example ">"&D3. Writing ">D3" does not read the number in D3.

AI was used in an automated way while working on this article. If you want to learn how to do it too, check out this project.

Kajo Rudziński

Newsletter KajoData

Let’s keep in touch.

I write about data analysis, learning and changing careers. My newsletter and the sign-up form are in Polish. If that works for you, I’d be glad to see you there.