Sub topic 5
Adding more conditions: criteria pairs and AND logic
This chapter assumes you can enter formulas in Google Sheets and read range notation such as A2:A100. It also assumes you have used COUNTIFS, SUMIFS, and AVERAGEIFS with a single condition. Here you add more conditions, learn how they combine, and learn the mistakes that come with them.
The criteria pair
Every condition in these functions is written as two arguments that travel together:
- A criteria range: the cells to test.
- A criterion: the test to apply to each cell in that range.
Together they form a criteria pair. To add a condition, you append another pair. You can add up to 127 pairs.
The three functions differ only in what comes before the pairs:
| Function | Arguments |
|---|---|
| COUNTIFS | `criteria_range1, criterion1, [criteria_range2, criterion2, ...]` |
| SUMIFS | `sum_range, criteria_range1, criterion1, [criteria_range2, criterion2, ...]` |
| AVERAGEIFS | `average_range, criteria_range1, criterion1, [criteria_range2, criterion2, ...]` |
COUNTIFS has no leading range because it counts rows and does not read values. SUMIFS and AVERAGEIFS put the range to total or average first, then the pairs.
All conditions must be true: AND logic
A row is included only when every criteria pair is true for that row. This is AND logic. Adding a pair can only keep the result the same or shrink it. It never makes the result larger.
Suppose a sales table has these columns:
| Column | Contents |
|---|---|
| A | Region |
| B | Product |
| C | Order date |
| D | Units |
| E | Revenue |
This formula averages revenue for rows in the West region that also have at least 10 units:
=AVERAGEIFS(E2:E100, A2:A100, "West", D2:D100, ">=10")The function checks each row from 2 to 100. A row counts only if column A is "West" and column D is 10 or more. A West row with 4 units is excluded. A row with 25 units in the East is excluded too.
The diagram shows how each row is tested.
Counting with several pairs
COUNTIFS follows the same pattern. This counts West rows with at least 10 units:
=COUNTIFS(A2:A100, "West", D2:D100, ">=10")SUMIFS is the same, with the sum range first:
=SUMIFS(E2:E100, A2:A100, "West", D2:D100, ">=10")If you keep the criteria pairs identical, you can swap the leading argument to move between a total, an average, and a count. Then the three results are consistent with each other: the SUMIFS result divided by the COUNTIFS result equals the AVERAGEIFS result.
The same column can appear twice
Nothing requires each criteria range to be a different column. Using one column in two pairs lets you set a lower and an upper bound. This counts West rows dated in January 2026:
=COUNTIFS(A2:A100, "West", C2:C100, ">="&DATE(2026,1,1), C2:C100, "<"&DATE(2026,2,1))The date column C2:C100 is used twice. The first pair keeps dates on or after 1 January. The second keeps dates before 1 February. Because the end is exclusive, a timestamp late on 31 January is still included. Later chapters cover the & operator and dates in detail. For now, notice that the two pairs on one column form a window between two limits.
The same idea works for numbers. To sum revenue for orders of 10 to 49 units:
=SUMIFS(E2:E100, D2:D100, ">=10", D2:D100, "<50")Pairs are independent of the first range
In SUMIFS and AVERAGEIFS, the sum or average range does not have to be one of the criteria ranges. It also can be one. These are both valid:
=SUMIFS(E2:E100, A2:A100, "West")
=SUMIFS(E2:E100, E2:E100, ">1000", A2:A100, "West")The second formula sums only West revenue values that exceed 1000. Here column E is both the thing being added and one of the things being tested.
Mistakes to watch for
Contradictory pairs return zero
Two pairs on the same column can rule out every row. This asks for a region that is both West and East in the same cell:
=COUNTIFS(A2:A100, "West", A2:A100, "East")No cell is both, so the result is 0. People often write this when they want "West or East". That is OR logic, which needs a different approach and is covered in a later chapter. If a COUNTIFS or SUMIFS unexpectedly returns 0, check whether two pairs exclude each other.
An unpaired argument causes a formula error
Each criteria range needs its criterion. If you leave one out, Sheets reports a formula parse error. A common cause is deleting a criterion while editing. Count the arguments after the first range: for SUMIFS and AVERAGEIFS the count of the remaining arguments must be even, and for COUNTIFS the total count must be even.
Argument order differs between functions
COUNTIFS starts with a criteria range. SUMIFS and AVERAGEIFS start with the range to total or average. When you convert a COUNTIFS into a SUMIFS, add the value range at the front instead of replacing something.
Ranges must match in size
Every range in the formula must have the same number of rows and columns. This formula mismatches the ranges:
=SUMIFS(E2:E100, A2:A99, "West")Sheets returns an error because E2:E100 has 99 rows and A2:A99 has 98. A later chapter covers this rule fully. When you add pairs, check that each new range begins and ends on the same rows as the others.
Numbers stored as text
A criterion like ">=10" compares numbers. If the Units column holds numbers that were pasted in as text, those cells will not satisfy the test, and the rows will quietly drop out of the result. If the totals look too low after you add a numeric pair, check that the cells are right-aligned numbers and not left-aligned text.
Locking the ranges
When you copy a formula down or across, relative references shift. To keep every criteria range fixed, use absolute references with dollar signs:
=SUMIFS($E$2:$E$100, $A$2:$A$100, G2, $D$2:$D$100, ">="&H1)Here G2 is relative, so it moves down one row when you fill the formula down, and each row of a summary can use its own region. H1 stays fixed in the formula text only if you also write it as $H$1; as written, it would shift. Decide which references should move and which should not before you copy.
A worked check
Take this small table in A1:E6.
| Region | Product | Order date | Units | Revenue |
|---|---|---|---|---|
| West | Widget | 2026-01-05 | 12 | 240 |
| West | Gadget | 2026-01-20 | 4 | 80 |
| East | Widget | 2026-01-22 | 15 | 300 |
| West | Widget | 2026-02-03 | 20 | 400 |
| West | Widget | 2026-01-28 | 10 | 200 |
Consider =SUMIFS(E2:E6, A2:A6, "West", D2:D6, ">=10").
- Row 2 is West with 12 units, so it counts: 240.
- Row 3 is West but has 4 units, so it fails the second pair.
- Row 4 has 15 units but is East, so it fails the first pair.
- Row 5 is West with 20 units, so it counts: 400.
- Row 6 is West with 10 units, and
>=10includes 10, so it counts: 200.
The result is 240 + 400 + 200 = 840. Now add the date window from earlier as two more pairs. Row 5 falls on 3 February and drops out, leaving 240 + 200 = 440.
Exercise
Using the table above, what does =COUNTIFS(A2:A6, "West", B2:B6, "Widget", D2:D6, ">10") return, and which rows does it keep?
Show answer
It returns 2. Row 2 (12 units) and row 5 (20 units) are West, Widget, and above 10 units. Row 6 has exactly 10 units, so ">10" excludes it. Row 3 is a Gadget and row 4 is East, so both fail an earlier pair.
Exercise
You want the total revenue of orders with 10 to 49 units in the East region. Write the SUMIFS formula for E2:E100, with region in A2:A100 and units in D2:D100.
Show answer
=SUMIFS(E2:E100, A2:A100, "East", D2:D100, ">=10", D2:D100, "<50")