Sub topic 5
Criteria with operators, wildcards, and dates
This chapter covers the criteria half of SUMIFS. You should already know how SUMIFS orders its arguments (sum range first, then range and criterion pairs) and how to anchor and bound ranges with $ and fixed row limits. Here the focus is on what you can put in a criterion, and on the mistakes that make a total look right while it is wrong.
What a criterion can be
Each criterion in SUMIFS is a single value that Excel tests against every cell in its paired criteria range. It can take four forms:
- A plain value or cell reference, such as
$A5. This means "equal to". - A text string that begins with an operator, such as
">=100"or"<>Cash". - A text string containing wildcards, such as
"Opex*". - A string built by joining an operator to a cell reference, such as
">="&C$3.
All criteria across the pairs must be true for a row to be included. SUMIFS combines pairs with AND. It has no built-in OR.
Comparison operators
The operators are =, <>, >, >=, < and <=. They go inside quotation marks, because the whole criterion is text that Excel parses.
| Criterion | Meaning |
|---|---|
| `"=Revenue"` | Equal to the text Revenue (same as `"Revenue"`) |
| `"<>Revenue"` | Not equal to Revenue |
| `">0"` | Greater than zero |
| `"<=1000"` | Less than or equal to 1000 |
| `"<>"` | Not blank |
| `"="` | Blank only |
A common use in a ledger is to separate inflows from outflows by sign:
=SUMIFS(Data!$F$2:$F$5000, Data!$B$2:$B$5000, $A5, Data!$F$2:$F$5000, ">0")Here column F is both the sum range and a criteria range. That is allowed. Excel evaluates the criteria first and then sums the rows that passed.
Using a cell as the threshold
When the threshold lives in an assumption cell, you cannot write the cell address inside the quotes. ">B2" compares against the literal text "B2". Join the operator and the reference instead:
=SUMIFS(Data!$F$2:$F$5000, Data!$F$2:$F$5000, ">"&$B$2)The & builds the string ">500" (for example) at calculation time. When the threshold changes, the total changes with it, and no formula needs editing.
Wildcards
Wildcards work only in text comparisons. There are two:
*matches any run of characters, including none.?matches exactly one character.
The Topic Spine example totals every category that starts with "Opex":
=SUMIFS(Data!$F$2:$F$5000, Data!$C$2:$C$5000, "Opex*")This picks up "Opex - Rent", "Opex - Payroll", and also a bare "Opex". Placing * on both sides, as in "*Payroll*", matches the word anywhere in the text.
Wildcards make roll-ups concise, but they depend entirely on how consistently the category names are written. If someone enters "Operating expense" for one row, the criterion silently skips it. Pair wildcard totals with a reconciliation check (covered in a later chapter) so a skipped row shows up.
Matching a literal asterisk or question mark
If the data itself contains * or ?, put a tilde in front to say "treat the next character literally". The criterion "Net~*" matches the text "Net*" and nothing else. A tilde matches itself only when written as ~~.
Wildcards with a cell reference
A wildcard can be joined to a cell value:
=SUMIFS(Data!$F$2:$F$5000, Data!$C$2:$C$5000, $A5&"*")If $A5 holds "Opex", the criterion becomes "Opex*". This lets a label column drive the grouping. One risk: if $A5 is empty, the criterion becomes "*", which matches every non-empty text cell. A blank label then returns a large, misleading total.
Dates as criteria
Excel stores a date as a serial number, so a date criterion is really a numeric comparison. The practical rules follow from that.
- Build the criterion from a date value, not a typed date string. A reference such as
C$3holds a true date, so">="&C$3becomes something like">=46023". This is reliable in any regional setting. - Avoid typing
">=1/1/2027"inside the formula. Excel has to parse that string, and the result depends on the user's locale. A day-first locale reads it differently from a month-first one. - Check that the Data sheet holds real dates. Dates imported as text look right but never satisfy a numeric comparison, so the SUMIFS returns zero.
A quick test is =ISNUMBER(Data!D2). A FALSE means the cell is text.
Month windows
To total one month, you need two criteria on the same date column: on or after the first day, and on or before the last day. The Topic Spine formula does this:
=SUMIFS(Data!$F$2:$F$5000, Data!$B$2:$B$5000, $A5, Data!$D$2:$D$5000, ">="&C$3, Data!$D$2:$D$5000, "<="&EOMONTH(C$3,0))EOMONTH(C$3,0) returns the last day of the month that contains C$3. The same date range appears twice because each pair holds one test.
Timestamps and the end-of-month trap
"<="&EOMONTH(C$3,0) compares against midnight at the start of the last day. A transaction on the last day with a time of 14:30 has a serial number slightly larger than the cutoff, so it is dropped. If the ledger carries timestamps, use a half-open window instead: on or after the first day, and strictly before the first day of the next month.
=SUMIFS(Data!$F$2:$F$5000, Data!$D$2:$D$5000, ">="&C$3, Data!$D$2:$D$5000, "<"&EDATE(C$3,1))This version has no gap at any time of day, and consecutive months never overlap. For ledgers that hold dates only, both forms give the same answer, but the half-open form is the safer default.
Common errors
- Operator outside quotes.
>0without quotes is a syntax error. Write">0". - Cell address inside quotes.
">C3"compares against the text "C3". Use">"&C3. - Mismatched range sizes. Every criteria range must have the same shape as the sum range. A range of 4,999 rows paired with one of 5,000 rows returns
#VALUE!. - Numbers stored as text. A criterion of
"100"matches both the number 100 and the text "100" in the criteria range, but the sum range ignores text amounts. Rows with text amounts contribute zero without any warning. - Case. SUMIFS ignores case, so "opex" and "OPEX" are equal.
- Trailing spaces. "Rent " does not equal "Rent". Clean keys with
TRIMat the source, not inside every formula. - Criteria over 255 characters. A criterion string longer than 255 characters returns
#VALUE!.
A worked layout
Suppose the ledger has the account in column B, the category in column C, the posting date in column D and the amount in column F. The roll-up sheet has account names down column A and month-start dates across row 3, starting in column C. The cell C5 would hold:
=SUMIFS(Data!$F$2:$F$5000, Data!$B$2:$B$5000, $A5, Data!$D$2:$D$5000, ">="&C$3, Data!$D$2:$D$5000, "<"&EDATE(C$3,1))Anchoring explains the dollar signs. The data ranges are fully anchored so they do not move when you copy the formula. $A5 locks the column, so every month reads the same account label, while the row can change. C$3 locks the row, so every account reads the same month header, while the column can change. One formula, copied across and down, fills the whole grid.
Exercise
A ledger has timestamps in column D, categories in column C, and amounts in column F (rows 2 to 5000). Cell B1 holds a minimum amount. Write a SUMIFS that totals all rows whose category ends with the word "Travel" and whose amount is greater than the value in B1. Then explain what happens to your result if a category is written "Travel " with a trailing space.
Show answer
=SUMIFS($F$2:$F$5000, $C$2:$C$5000, "Travel", $F$2:$F$5000, ">"&$B$1). The wildcard before Travel matches any text that ends in Travel. The threshold is joined with & so that it reads the value of B1. A category written "Travel " with a trailing space does not end in Travel, so that row is silently left out and the total is too low. Cleaning the keys with TRIM at the source, or using "Travel", avoids the gap, and a reconciliation check against the source total would reveal it.
Exercise
Why is "<"&EDATE(C$3,1) a safer upper bound for a month than "<="&EOMONTH(C$3,0) when the ledger contains timestamps?
Show answer
EOMONTH returns midnight at the start of the last day, so any transaction later that day has a larger serial number and is excluded. EDATE(C$3,1) returns the first day of the next month at midnight, and the strict "<" comparison includes every moment before it, so there is no gap and no overlap between months.