Sub topic 8
Keeping Ranges the Same Size
This chapter assumes you can enter formulas, use ranges such as A2:A100, and distinguish text, numbers, and dates. The key rule is simple: every range used by COUNTIFS, SUMIFS, or AVERAGEIFS must cover the same set of rows.
What “the same size” means
A range’s size includes both its number of rows and its number of columns. In a row-based data table, your ranges usually have one column and the same number of rows.
For example, these ranges all cover rows 2 through 100:
| Range | Rows | Columns |
|---|---|---|
| `A2:A100` | 99 | 1 |
| `D2:D100` | 99 | 1 |
| `E2:E100` | 99 | 1 |
They are compatible because row 2 in each range describes the same record, as do rows 3 through 100.
How the functions align rows
COUNTIFS checks each row in its criteria ranges. SUMIFS checks the criteria ranges and takes a value from the corresponding row in its sum range. AVERAGEIFS does the same with its average range.
=SUMIFS(E2:E100, A2:A100, "West", D2:D100, ">=10")This formula tests the Region and Units cells on each row. When both conditions are true, it adds the Revenue value from column E on that same row.
The alignment is positional:
A2is checked withD2, andE2is added if both conditions pass.A3is checked withD3, andE3is added if both conditions pass.- The process continues through row 100.
A range with a different endpoint breaks this alignment.
=SUMIFS(E2:E100, A2:A99, "West")Here, the sum range has 99 rows, but the criteria range has 98 rows. Google Sheets cannot reliably pair every value, so the formula can return an error instead of a result.
Common mismatch patterns
Check these details when a conditional aggregation formula fails:
- One range starts on row 2 while another starts on row 1.
- One range ends at row 100 while another ends at row 99.
- A criteria range uses a full column such as
A:A, while the sum range usesE2:E100. - One reference points to a horizontal range, such as
A2:J2, while the others are vertical. - A copied formula changes one endpoint because its references were not fixed.
Absolute references prevent ranges from moving when you fill a formula down or across.
=IFERROR(AVERAGEIFS($E$2:$E$100, $A$2:$A$100, G2), "No matches")The dollar signs fix the data ranges. G2 remains relative, so each summary row can use a different region. The fixed ranges must still have matching dimensions.
A visual way to check alignment
Before troubleshooting the criteria text, compare the first and last row of every range. If those boundaries match, then inspect the conditions themselves.
Exercise
What is wrong with =COUNTIFS(A2:A100, "West", D2:D99, ">=10"), and how would you fix it?
Show answer
The criteria ranges contain different numbers of rows. Change D2:D99 to D2:D100, or change both ranges to another identical boundary.