Sub topic 15
Putting it together: a summary table driven by criteria cells
This chapter combines the earlier pieces into one reusable summary table. It assumes you can enter formulas in Google Sheets, read ranges such as A2:A100, and use COUNTIFS, SUMIFS, and AVERAGEIFS with several criteria pairs. It also assumes you know how & joins an operator to a cell value and why AVERAGEIFS can return #DIV/0!.
What you are building
A summary table is a small block of formulas. Each row is one group, such as a region. Each column is one measure, such as row count, total revenue, or average revenue. The group names and thresholds sit in cells, and the formulas read them. To change what the table reports, you edit a cell and leave the formulas alone.
The example uses this data layout, starting in row 2 with headers in row 1:
| Column | Header | Contents |
|---|---|---|
| A | Region | Text such as West, East, North |
| B | Product | Text such as Widget, Gadget |
| C | Date | Order date |
| D | Units | Number |
| E | Revenue | Number |
The data runs through row 100.
Step 1: Lay out the criteria cells
Put the inputs in a block away from the data, for example in columns G through J. This layout is used for the rest of the chapter:
| Cell | Content |
|---|---|
| G1 | Region |
| H1 | Count |
| I1 | Total revenue |
| J1 | Average revenue |
| G2 | West |
| G3 | East |
| G4 | North |
| L1 | Minimum units |
| L2 | 10 |
Column G holds the group names. Cell L2 holds a numeric threshold that every row of the table shares. Each region name is typed once, so a typo can only happen in one place.
Step 2: Write the first row
Write the three formulas in row 2, then fill them down.
Count in H2:
=COUNTIFS($A$2:$A$100, $G2, $D$2:$D$100, ">="&$L$2)Total revenue in I2:
=SUMIFS($E$2:$E$100, $A$2:$A$100, $G2, $D$2:$D$100, ">="&$L$2)Average revenue in J2:
=IFERROR(AVERAGEIFS($E$2:$E$100, $A$2:$A$100, $G2, $D$2:$D$100, ">="&$L$2), "No matches")Each formula has two criteria pairs. The first compares the Region column to the group name in column G. The second compares Units to the threshold in L2. A row is counted only if both are true, because criteria pairs combine with AND.
Note the argument order. SUMIFS and AVERAGEIFS put the range to add or average first. COUNTIFS has no such range, so it starts directly with the first criteria range.
Step 3: Choose the right references
The reference style decides whether the formulas survive being filled down. Each part is anchored on purpose:
| Part | Style | Reason |
|---|---|---|
| `$A$2:$A$100`, `$D$2:$D$100`, `$E$2:$E$100` | Fully absolute | The data range must not shift when you fill down. |
| `$G2` | Column absolute, row relative | Moves to `$G3`, `$G4` as you fill down, and stays in column G if you copy across. |
| `$L$2` | Fully absolute | Every row uses the same threshold. |
If you leave out the dollar signs on the data ranges, row 3 would read A3:A101 and row 4 A4:A102. The ranges slide down the sheet and the results become wrong, often without any error. This is the most common failure in summary tables.
Step 4: Add a total row
A total row lets you check the table against the data. Put "All" in G5 and use these formulas:
=SUM(H2:H4)=SUM(I2:I4)Compare the count and the revenue total with a direct calculation over the whole data set:
=COUNTIFS($D$2:$D$100, ">="&$L$2)=SUMIFS($E$2:$E$100, $D$2:$D$100, ">="&$L$2)If the two sets of numbers differ, one of three things is usually true. A region exists in the data but is missing from column G. A region name in column G is misspelled. A region name in the data has a stray space, such as West with a trailing space, so it does not equal West. Do not total the averages in column J. An average of averages is not the overall average unless every group has the same row count. For an overall average, run AVERAGEIFS over the whole range.
Step 5: Extend with more criteria cells
Once the pattern works, adding a dimension means adding one cell and one criteria pair. To limit the table to one product, put a product name in L4 and add a pair to each formula:
=COUNTIFS($A$2:$A$100, $G2, $D$2:$D$100, ">="&$L$2, $B$2:$B$100, $L$4)To make the product filter optional, you can use a wildcard. Set L4 to * and the pair $B$2:$B$100, $L$4 matches any non-empty text. A product cell that is truly blank is not matched by *, so rows with no product drop out. This is a trade-off to know about before relying on it.
For a date window, use two cells, L6 for the start and L7 for the exclusive end, and add two pairs on the same date column:
=SUMIFS($E$2:$E$100, $A$2:$A$100, $G2, $C$2:$C$100, ">="&$L$6, $C$2:$C$100, "<"&$L$7)Each added pair must use a range with the same number of rows as the others. All of them here run from row 2 to row 100.
Step 6: Make the table survive new data
Fixed ranges such as $A$2:$A$100 ignore rows added below row 100. There are two common fixes:
- Use whole-column ranges such as
$A:$A. This is simple and works with COUNTIFS, SUMIFS, and AVERAGEIFS. The header row is text, so it is not counted in numeric ranges, and it does not match your criteria unless a header equals a group name. - Use a range that goes well past the data, such as
$A$2:$A$1000. Blank rows do not match a text criterion, so they are harmless, and every range stays the same size.
Whichever you choose, apply it to every range in the formula so the sizes still match.
Common problems
| Symptom | Likely cause | Fix |
|---|---|---|
| `#VALUE!` | Ranges have different sizes | Make every range the same number of rows. |
| Count is 0 for a region that exists | Trailing space or different spelling | Clean the data or the criteria cell, for example with `TRIM`. |
| Average shows "No matches" | No row meets all criteria | Check the threshold and the group name. This is correct behavior. |
| Numbers change after fill-down | Missing `$` on the data ranges | Anchor the ranges. |
| Threshold has no effect | Criterion written as `">=L2"` instead of `">="&$L$2` | Join the operator and the cell with `&`. |
Check your understanding
Exercise
The table in column G lists regions, and the formula in H2 is =COUNTIFS(A2:A100, G2, D2:D100, ">="&L2). You fill it down to H3 and the count looks too low. What is wrong, and what is the corrected formula for H2?
Show answer
The references are relative, so in H3 the ranges become A3:A101 and D3:D101 and the threshold becomes L3, which is empty. Anchor the data ranges and the threshold: =COUNTIFS($A$2:$A$100, $G2, $D$2:$D$100, ">="&$L$2).
Exercise
Write a J2 formula that averages Revenue (E2:E100) for the region in G2, only for rows dated on or after the date in L6, and shows "No matches" when nothing qualifies. Use the date column C2:C100.
Show answer
=IFERROR(AVERAGEIFS($E$2:$E$100, $A$2:$A$100, $G2, $C$2:$C$100, ">="&$L$6), "No matches")