Sub topic 6
Comparison operators in criteria: >, <, >=, <=, <>, =
This chapter covers how to put comparison operators inside the criteria of COUNTIFS, SUMIFS, and AVERAGEIFS. It assumes you can already enter formulas, read ranges such as A2:A100, and write a basic criteria pair like A2:A100, "West". It also assumes you know that numbers, text, and dates are different kinds of values in a cell.
Why criteria need operators
So far a criterion has been a plain value, such as "West". A plain value means "equals this value." Many questions need a different test:
- Which orders have 10 or more units?
- What is the total revenue of rows where the discount is above zero?
- How many rows have a Region that is not "West"?
You answer these by writing the operator at the start of a text string. The function reads the operator, then reads the rest of the string as the value to compare against.
The six operators
| Operator | Meaning | Example criterion |
|---|---|---|
| `=` | equal to | `"=West"` |
| `<>` | not equal to | `"<>West"` |
| `>` | greater than | `">10"` |
| `<` | less than | `"<10"` |
| `>=` | greater than or equal to | `">=10"` |
| `<=` | less than or equal to | `"<=10"` |
Three rules apply to all of them:
- The whole criterion is one text string in quotes. The operator and the value sit together inside the quotes, as in
">=10". - The operator comes first.
"10>="is not valid. Google Sheets would treat it as a literal piece of text and match nothing. - If you leave the operator off, the criterion means equals.
"West"and"=West"behave the same.
A first example
Assume the sheet has these columns: Region in A, Product in B, Date in C, Units in D, and Revenue in E, with data in rows 2 to 100.
To count rows with at least 10 units:
=COUNTIFS(D2:D100, ">=10")To sum Revenue for rows with at least 10 units, put the range to add first, then the criteria pair:
=SUMIFS(E2:E100, D2:D100, ">=10")To average Revenue for the same rows:
=AVERAGEIFS(E2:E100, D2:D100, ">=10")The criteria range (D2:D100) and the range being summed or averaged (E2:E100) are different columns. This is allowed and is the usual pattern. The test runs on Units, and the result comes from Revenue.
Combining operators with AND
Each criteria pair is an independent test, and every pair must be true for a row to count. You can put two operators on the same column to build a band:
=COUNTIFS(D2:D100, ">=10", D2:D100, "<50")This counts rows where Units is at least 10 and below 50. Using the same range twice is normal. You can also mix a numeric test with a text test:
=AVERAGEIFS(E2:E100, A2:A100, "West", D2:D100, ">=10")This averages Revenue for rows in the West region that also have at least 10 units.
Not equal: the `<>` operator
"<>West" matches every row where the cell is anything other than "West." This includes blank cells, because an empty cell is not equal to "West."
=COUNTIFS(A2:A100, "<>West")If you want to exclude "West" and also ignore blanks, add a second pair:
=COUNTIFS(A2:A100, "<>West", A2:A100, "<>")The second pair, "<>" with no value after it, means "not empty." A later chapter covers blank and non-blank matching in more detail.
Text comparisons with = and <> are not case-sensitive, so "<>west" and "<>West" give the same result.
Comparing against a cell value
Hard-coding 10 inside a formula makes the threshold hard to change. The usual fix is to keep the threshold in a cell and join the operator to it with the & operator, which joins text together.
Suppose H1 holds the number 10:
=SUMIFS(E2:E100, D2:D100, ">"&H1)If H1 is 10, the criterion becomes the text ">10". If you change H1 to 25, the formula follows without being edited. The operator stays inside quotes. The cell reference stays outside them. Leaving the quotes off the operator, as in >H1, is a formula error.
A later chapter covers building criteria from cells in full. For now, remember that the pattern is "operator" & cell.
Passing a cell directly
If you pass a cell reference with no operator, such as D2:D100, H1, the criterion is "equals the value in H1." That works for exact matches only. For anything other than equals, you must build the string with &.
A related trap: if H1 itself contains text such as >10, then D2:D100, H1 also works, because the cell's text already starts with an operator. This can be handy for letting a user type a full condition, but it is easy to forget it is happening.
How the comparison treats types
The value after the operator is read as a number, a date, or text. The function then compares it only against cells of the same kind.
">10"compares against numbers. Text cells such as"abc"are ignored, not counted.- Numbers stored as text (for example
"15"with a left-aligned, text-formatted cell) can be missed by numeric comparisons. If counts look too low, check that the column really holds numbers. ">M"compares text alphabetically. It matches text that sorts after "M," such as "Zeta." This is occasionally useful, but most work uses numbers.- Dates are numbers in Sheets, so
">"&DATE(2026,1,1)works. Date filtering gets its own chapter.
Common errors
| Symptom | Likely cause | Fix |
|---|---|---|
| Result is 0 but matches exist | Operator written after the value, or the number is stored as text | Put the operator first; convert the column to real numbers |
| `#ERROR!` (formula parse error) | Missing quotes around the operator, or a missing `&` | Write `">"&H1`, not `>H1` or `">" H1` |
| `<>` count is higher than expected | Blank cells are included in "not equal" | Add a `"<>"` pair on the same range |
| `#VALUE!` | Ranges have different sizes | Make every range the same height and width |
| AVERAGEIFS shows `#DIV/0!` | No row passed every test | Check the criteria, or wrap in IFERROR |
Equality with `=` and special cases
Writing "=" followed by nothing, as in "=", matches only truly empty cells. That differs from "", which can also match cells containing an empty string returned by a formula. For plain empty cells they usually agree, but the distinction matters when a formula column returns "".
When you need to match a value that begins with an operator character, for example a literal text cell holding >10, put = in front: "=>10". The first = is the operator, and the rest is treated as the value.
A worked example: a threshold table
You can lay out several thresholds in cells and fill one formula down. Put these in G2:G4:
- G2: 10
- G3: 25
- G4: 50
In H2, enter:
=COUNTIFS($D$2:$D$100, ">="&G2)Fill H2 down to H4. The absolute references ($D$2:$D$100) keep the range fixed, while G2 changes to G3 and G4. Each row shows how many orders reached that many units.
Exercise
Using the Units column D2:D100 and Revenue column E2:E100, write one formula that sums Revenue for rows where Units is more than 5 and at most 20. Then write the same formula with the lower limit read from cell H1 and the upper limit read from H2.
Show answer
Hard-coded: =SUMIFS(E2:E100, D2:D100, ">5", D2:D100, "<=20"). With cells: =SUMIFS(E2:E100, D2:D100, ">"&H1, D2:D100, "<="&H2). Both use two pairs on the same criteria range, and a row must pass both.
Exercise
A formula =COUNTIFS(A2:A100, "<>West") returns 40, but you expected only rows that have a Region filled in and are not West. What is the likely problem, and how do you fix it?
Show answer
Blank cells in A2:A100 are not equal to "West," so they are counted. Add a second pair that excludes blanks: =COUNTIFS(A2:A100, "<>West", A2:A100, "<>").