Math and trigonometry functions
SUMIF
Matches all 32 recorded answers
Recorded: 32 workbook cells. How we measure this · See the Rust code
Local names in 40 languages
| Language | Name in Excel |
|---|---|
| Arabic | SUMIF |
| Bulgarian | SUMIF |
| Czech | SUMIF |
| Danish | SUM.HVIS |
| German | SUMMEWENN |
| Greek | SUMIF |
| English (Australia) | SUMIF |
| English (United Kingdom) | SUMIF |
| English (United States) | SUMIF |
| Spanish | SUMAR.SI |
| Estonian | Funktsioon SUMIF |
| Finnish | SUMMA.JOS |
| French | SOMME.SI |
| Hebrew | SUMIF |
| Croatian | SUMIF |
| Hungarian | SZUMHA |
| Indonesian | SUMIF |
| Italian | SOMMA.SE |
| Japanese | SUMIF |
| Korean | SUMIF |
| Lithuanian | SUMIF |
| Latvian | SUMIF |
| Norwegian | SUMMERHVIS |
| Dutch | SOM.ALS |
| Polish | SUMA.JEŻELI |
| Portuguese (Brazil) | SOMASE |
| Portuguese (Portugal) | SOMA.SE |
| Romanian | SUMIF |
| Russian | СУММЕСЛИ |
| Slovak | SUMIF |
| Slovenian | SUMIF |
| Serbian (Latin) | SUMIF |
| Swedish | SUMMA.OM |
| Thai | SUMIF |
| Turkish | ETOPLA |
| Ukrainian | SUMIF |
| Vietnamese | SUMIF |
| Chinese (Simplified) | SUMIF |
| Chinese (Hong Kong) | SUMIF |
| Chinese (Traditional) | SUMIF |
Names from Microsoft's support site.
What it does
SUMIF(range, criteria, [sum_range])
SUMIF(range, criteria, [sum_range]) adds the values of sum_range at the positions where
range satisfies criteria. Written as a filtered reduction:
M = { i : P(range_i) } the matched index set
SUMIF = SUM over i in M of s_i where s is sum_range, or range itself if omitted
Two things are worth separating in that definition, because the function's whole difficulty lives in the gap between them:
- The predicate
Pis applied torange. It is not an arbitrary expression; it is a criteria value in the family's small criteria language — a number, a text string, a comparison written as text (">5"), or a wildcard pattern. - The values summed come from
sum_range, a different range, addressed positionally rather than by intersection. That indirection is the source of the sizing rule below.
Microsoft describes the arguments as the range "you want evaluated by criteria", the criteria
"in the form of a number, expression, a cell reference, text, or a function that defines which
cells will be added", and sum_range as "the actual cells to add, if you want to add cells
other than those specified in the range argument".
Arguments
| Argument | Meaning | Default |
|---|---|---|
range | The cells evaluated by criteria. Required. | — |
criteria | The condition selecting which cells are added. Required. | — |
sum_range | The cells actually added. Optional. | range |
The criteria language, as documented. Criteria may be a number, an expression, a cell
reference, text, or a function. Text criteria and any criteria containing logical or
mathematical symbols must be enclosed in double quotation marks — so ">5" is a string that the
function parses as a comparison, not a comparison the formula evaluates. Wildcards are
available: ? matches a single character, * matches any sequence, and ~ escapes a literal
? or *.
A documented limitation worth quoting for its unusual candour. Microsoft states: "The SUMIF function returns incorrect results when you use it to match strings longer than 255 characters." Not an error value — incorrect results. That is a documented silent-wrong-answer condition, and it is rare enough in Microsoft's function reference to be worth flagging: a formula matching long strings is documented to produce a number that is simply not the right number, with no diagnostic anywhere. Any workbook matching on long free-text keys is in that territory.
Try it
Quirks
The sum_range sizing rule
This is the position most readers get wrong, and the documentation is explicit about it: "Sum_range should be the same size and shape as range. If it isn't, performance may suffer, and the formula will sum a range of cells that starts with the first cell in sum_range but has the same dimensions as range."
In other words: sum_range is treated as an anchor, not as an extent. Only its top-left
cell is honoured; the shape is taken from range. SUMIF(A1:A10, ">5", B1) therefore sums
B1:B10, and SUMIF(A1:A10, ">5", B1:B3) also sums B1:B10 — silently reading seven cells the
author never named.
The consequences are worth stating plainly, because none of them produce an error:
- A
sum_rangethat is shorter thanrangereads past its own end into whatever lies below. - A
sum_rangewhose orientation differs fromrange— a row whererangeis a column — is re-shaped torange's dimensions from its anchor, so the cells summed may have no relation to the ones written in the formula. - Inserting or deleting rows inside
rangechanges which cellssum_rangecovers, without touching thesum_rangereference at all.
The defensive practice is simply to write both ranges with identical shapes and to keep them adjacent, so a structural edit moves both together.
Result and edge cases
Returns Number.
- No matches: zero.
SUMIFdoes not report an empty match set as an error, which means an entirely mistyped criterion is indistinguishable from a genuine zero total. - Text and logicals in
sum_range: not addressed on theSUMIFpage. The aggregate family's range-scan policy is the governing rule; see Coercion and lifting. The Handbook has not checked which scan policy this surface uses. - Numeric criteria matching is not exact IEEE equality. This is the substantive finding on this surface and it is discussed under Numerical notes.
Errors
| Error | Condition | Source |
|---|---|---|
#VALUE! | An argument does not resolve to a range or a usable criteria value | Shared call model; not enumerated on the SUMIF page |
| propagated | An error value among the scanned data surfaces as that error | Shared coercion rules and the module's ReductionFold |
Microsoft's page documents no error conditions for SUMIF. It documents a wrong-answer
condition instead (the long-string limitation above), which is a different and arguably worse
thing.
How to implement
Numerical notes
SUMIF has two numerical characters, and they are unrelated to each other.
What that means for a reader of SUMIF: a criterion of 0.3 can match a stored value of
0.1+0.2, even though those are different doubles. Whether you regard that as a bug or as the
only humane behaviour for a spreadsheet, it is a real semantic property and it changes which
cells enter the sum. It also means the matched set is not determined by the bits alone, so two
implementations that agree on IEEE arithmetic can still disagree on SUMIF.
The record's counts are not this surface's counts. EV-STRUCT-0001 carries an explicit
reader warning that its total is over hand-picked lanes spanning both arms, not a pass rate for
any surface, and it records an unresolved discrepancy in the upstream lane enumeration. SUMIF
appears there with the subject role body-only. This page states none of those figures; the
evidence layer renders them beside it with their warnings attached.
Rust code
Show the CalcFunc source of this function
Quoted from the public repository DnaCalc/DnaCalc, crates calc-func and calc-fml, at commit 9e1884369a67. Comments are the source's own. A kernel shared with other functions appears once, on its module page.
SUMIF · 1 lines · calc-func/src/catalogue/conditional.rs on GitHubconditional(SUMIF, "SUMIF", (2, 3), SUM_RANGE, sumif)
sumif · 11 lines · calc-func/src/catalogue/conditional.rs on GitHub/// SUMIF: the numbers of the sum range, or of the range when it is omitted, in the rows whose
/// range cell meets the criterion, added from 0. A total that overflows is #NUM!.
fn sumif(
arguments: &[CalcValue],
services: &mut EvalServices<'_>,
) -> Result<CalcValue, FunctionFault> {
let site = Site::new(SUMIF, services);
Site::finish(
single(&site, arguments, services, true).and_then(|plan| total(&site, &plan, services)),
)
}
Kernels shared with other functions
readercatalogue/aggregateread_referencecatalogue/aggregatenumberscatalogue/comparisonin_bandcatalogue/comparisonRounded::upcatalogue/comparisonRoundings::ofcatalogue/comparisonRoundings::disjointcatalogue/comparisontextscatalogue/comparisoncomparecatalogue/comparison/collationweighedcatalogue/comparison/collationmeasured_iteration_extensioncatalogue/comparison/collationtablecatalogue/comparison/sort_keydecode64catalogue/comparison/sort_keyReader::bytecatalogue/comparison/sort_keyReader::varintcatalogue/comparison/sort_keyReader::donecatalogue/comparison/sort_keyin_rangescatalogue/comparison/sort_keybuildcatalogue/comparison/sort_keyhan_basecatalogue/comparison/sort_keyderivecatalogue/comparison/sort_keyshared_jamo_tailscatalogue/comparison/sort_keyordinary_jamo_prefixcatalogue/comparison/sort_keyindependent_jamo_suffixcatalogue/comparison/sort_keyjamo_leading_primarycatalogue/comparison/sort_keyleading_ordercatalogue/comparison/sort_keyBefore::separate_specialcatalogue/comparison/sort_keyGathered::kanacatalogue/comparison/sort_keyGathered::unitcatalogue/comparison/sort_keypartscatalogue/comparison/sort_keydiacritic_ordercatalogue/comparison/sort_keydiacriticscatalogue/comparison/sort_keyconditionalcatalogue/conditionaltotalcatalogue/conditionalRange::shapecatalogue/conditionalrangecatalogue/conditionalsinglecatalogue/conditionalPlan::each_matchedcatalogue/conditionalrowcatalogue/conditionaloffsetcatalogue/conditionalread_rangecatalogue/conditionalverdictscatalogue/conditionaltarget_cellscatalogue/conditionalusedcatalogue/conditionalMatch::ofcatalogue/conditionalMatch::negatedcatalogue/conditionalOp::holdscatalogue/conditionalOp::is_equalitycatalogue/conditionalspellscatalogue/conditionalcriterioncatalogue/conditionalrankcatalogue/conditionalcriterion_textcatalogue/conditionaldecidedcatalogue/conditionalCriterion::verdictcatalogue/conditionalequalitycatalogue/conditionalis_surrogatecatalogue/conditionalwildcardcatalogue/conditionallow32decimalNatural::from_u64decimalNatural::pow10decimalNatural::normalizedecimalNatural::is_zerodecimalNatural::mul_add_smalldecimalNatural::times_pow10decimalNatural::times_pow5decimalNatural::times_pow2decimalExactDecimal::binarydecimaltextported/text_kernelstext_from_strported/text_kernelsfold_unitported/text_kernelspush_singleton_or_originalported/text_kernelspush_lowerported/text_kernelslowerported/text_kernels
Argument and result plumbing
operandcoerce
No implementation has been published with a Handbook test suite for this function.
Version differences
No comparison between specific Excel builds is recorded here yet. This does not establish that all builds behave alike.
Alternatives
Relationships
SUMIFS— the multi-criterion successor, and note the argument order is different:SUMIFS(sum_range, criteria_range1, criteria1, ...)puts the summed range first, whereSUMIFputs it last. Converting one to the other by adding a criterion pair does not work; the arguments have to be rearranged.SUMIFSalso requires its ranges to match in shape rather than reshaping from an anchor, which makes it the safer function even for a single criterion.COUNTIF/COUNTIFS— the same predicate machinery with a counting reduction.COUNTIFis a co-subject of the evidence record attached to this page.AVERAGEIF/AVERAGEIFS,MAXIFS,MINIFS— the rest of the module.SUMPRODUCT— the general alternative, whose conditions are arbitrary array expressions rather than criteria strings. It is more general and less readable;SUMIFis the right tool when the condition fits the criteria language.FILTER+SUM— the modern dynamic-array route, which makes the matched set visible as a value rather than hiding it inside the aggregation.DSUM— the database-family equivalent, with criteria expressed as a range rather than as a string.- Confused with:
SUMIFS(argument order), and withSUMIFover asum_rangeof the wrong shape (the sizing rule above).
Named variants
No named variants are recorded yet.
Suggest a correction or contribute an implementation · For agents