Sub topic 7
Using >, <, >=, <=, and <> in criteria
This chapter assumes you can already write a basic SUMIFS, COUNTIFS, or AVERAGEIFS formula with an exact-match criterion such as "West". It also assumes you know absolute and relative references. Here you will learn how to test for "greater than", "not equal to", and similar conditions, and how to avoid the errors that usually go with them.
All examples use the sample sales layout from earlier in the tutorial. Headers are in row 1, data runs from row 2 to row 100, and column D holds Amount.
A: Date B: Region C: Product D: Amount E: Notes
2025-01-05 West Laptop 1200
2025-01-09 East Monitor 300 Backorder
2025-02-02 West Monitor 310
2025-02-14 North Laptop 1150 GiftResults quoted below are for these four data rows. Rows 6 to 100 are empty.
How a criterion with an operator is read
A criterion is normally a single piece of text. If it starts with a comparison operator, Excel splits it into two parts: the operator, and the value after it. It then tests each cell in the criteria range against that value. If the criterion has no operator, Excel assumes "equals".
| Operator | Meaning | Example criterion |
|---|---|---|
| `=` | equal to (the default) | `"=West"` or `"West"` |
| `<>` | not equal to | `"<>West"` |
| `>` | greater than | `">500"` |
| `<` | less than | `"<500"` |
| `>=` | greater than or equal to | `">=500"` |
| `<=` | less than or equal to | `"<=500"` |
The operator must be the first thing in the string. It must also be written exactly as shown. "=>500" and "≥500" are not operators, so Excel treats the whole string as literal text to match. The formula then usually returns 0 with no error, which is easy to miss.
Numeric comparisons
Put the operator and the number inside quotation marks.
=SUMIFS(D2:D100, D2:D100, ">500")This adds every Amount above 500. The sum range and the criteria range can be the same column. On the sample rows the result is 2350 (1200 + 1150).
=COUNTIFS(D2:D100, ">=1000")This counts rows with an Amount of at least 1000. The result is 2.
The difference between > and >= matters at the boundary. An Amount of exactly 1000 is counted by ">=1000" but not by ">1000". Decide which you mean before you write the formula.
Between two values
To set both a lower and an upper limit, use the same range in two pairs. Both conditions must be true for a row to count, because conditions in one formula are combined with AND.
=SUMIFS(D2:D100, D2:D100, ">=300", D2:D100, "<=1000")This adds Amounts from 300 to 1000 inclusive. On the sample rows it gives 610 (300 + 310).
Using `<>` for "not equal to"
<> excludes a value.
=SUMIFS(D2:D100, B2:B100, "<>West")This adds Amount for every region except West. The sample result is 1450 (East 300 + North 1150).
Blank cells and `<>`
"<>West" is true for any cell that is not "West", and that includes empty cells. For SUMIFS this is harmless here, because empty rows have no Amount to add. For COUNTIFS it inflates the result, because the 95 empty rows in B6:B100 are counted along with the real ones.
=COUNTIFS(B2:B100, "<>West")On the sample layout this returns 97, not 2. To count only real rows, add a second condition that excludes blanks:
=COUNTIFS(B2:B100, "<>West", B2:B100, "<>")A lone "<>" means "not empty". The formula above returns 2. The same idea counts rows that have a note:
=COUNTIFS(E2:E100, "<>")The result is 2 (Backorder and Gift). Blank criteria get their own chapter later.
Taking the value from a cell
Hard-coded numbers make a formula hard to reuse. To read the threshold from a cell, join the operator text and the cell value with &.
=SUMIFS(D2:D100, B2:B100, "West", D2:D100, ">=" & G1)If G1 contains 500, Excel builds the criterion ">=500". Changing G1 changes the result without touching the formula.
Note the placement of the quotation marks. The operator is text, so it goes in quotes. The cell reference is not text, so it stays outside them.
| Written as | What Excel receives | Result |
|---|---|---|
| `">=" & G1` | `">=500"` | Compares Amount to 500 |
| `">=G1"` | the literal text `">=G1"` | Compares Amount to the text "G1", so nothing matches |
| `G1` | the contents of G1 | Works only if G1 itself holds `">=500"` |
The third form is useful if you want users to type the whole condition, operator included, into one input cell.
Comparing text and dates
Comparison operators also work on text. Excel compares letters alphabetically and ignores case.
=COUNTIFS(B2:B100, ">M")This counts regions that sort after "M", which here means "North" and "West". Blank cells are not included, because a text comparison only considers text cells.
Dates are stored as numbers, so the same operators work on them. Build the date with DATE instead of typing it as text.
=SUMIFS(D2:D100, A2:A100, ">=" & DATE(2025,2,1))This adds all Amounts from 1 February 2025 onward. The sample result is 1460 (310 + 1150). The next chapters cover date ranges in more detail.
Common problems
- Numbers stored as text. A numeric criterion such as
">500"only matches cells that hold real numbers. If Amounts were imported as text, the formula returns 0 even though the cells look correct. A left-aligned value or a green corner triangle is the usual sign. Convert the column to numbers. - Missing quotation marks.
=SUMIFS(D2:D100, D2:D100, >500)is a syntax error. The criterion must be a quoted string. - Mixed-up operator order.
"=>500"and"=<500"are not valid operators. Write">="and"<=". - Boundary mistakes. Use
>=and<=when the limit itself should count. Use>and<when it should not. - Unexpected blanks with
<>. Add"<>"as a second condition when counting, as shown above.
Exercise
Write one formula that counts the rows where Region is not East, Amount is at least 300, and the Region cell is not blank. Then give the result for the four sample rows.
Show answer
=COUNTIFS(B2:B100, "<>East", B2:B100, "<>", D2:D100, ">=300"). The West rows (1200 and 310) and the North row (1150) pass all three tests, and the East row is excluded, so the result is 3.
Exercise
Cell G1 holds 1000. Write a SUMIFS formula that adds Amount for rows where Amount is below the value in G1. Why does "<G1" not work?
Show answer
=SUMIFS(D2:D100, D2:D100, "<" & G1). The text "<G1" is passed to Excel as a literal string, so Excel compares each Amount to the word "G1" and matches nothing. The & joins the operator to the value in G1 and produces "<1000". On the sample rows the result is 1810 (300 + 310 + 1200 is not included, because 1200 is not below 1000, so the sum is 610).