The request

From Andrew Ramos, Marketing Manager
Your goal
The channel to report on is in G1. In G3, count the orders in B2:B30 whose channel matches G1 with COUNTIF. In G4, add up their subtotals (C2:C30) with SUMIF. Point at G1, don't type the channel into the formulas.
- Fill
G3:G4with the right valuesnot done yet - With formulas, not typed numbersnot done yet
- Use
COUNTIFSUMIFnot done yet
Your sheet
| A | B | C | D | E | F | G | H | |
|---|---|---|---|---|---|---|---|---|
| 1 | order_id | channel | subtotal | Channel | app | |||
| 2 | 12416 | app | 127.95 | |||||
| 3 | 12417 | app | 682.96 | Orders | ||||
| 4 | 12418 | app | 37.98 | Revenue | ||||
| 5 | 12419 | web | 19.19 | |||||
| 6 | 12420 | app | 51.99 | |||||
| 7 | 12421 | web | 119.96 | |||||
| 8 | 12422 | web | 189.94 | |||||
| 9 | 12423 | app | 286.98 | |||||
| 10 | 12424 | marketplace | 57.96 | |||||
| 11 | 12425 | web | 3476.00 | |||||
| 12 | 12426 | web | 789.95 | |||||
| 13 | 12427 | app | 443.97 | |||||
| 14 | 12428 | app | 189.98 | |||||
| 15 | 12429 | app | 1599.00 | |||||
| 16 | 12430 | web | 809.92 | |||||
| 17 | 12432 | app | 139.17 | |||||
| 18 | 12433 | web | 258.99 | |||||
| 19 | 12434 | web | 18.99 | |||||
| 20 | 12435 | app | 11.99 | |||||
| 21 | 12436 | app | 104.99 | |||||
| 22 | 12437 | app | 177.94 | |||||
| 23 | 12438 | app | 13.99 | |||||
| 24 | 12439 | app | 1737.99 | |||||
| 25 | 12440 | app | 1932.95 | |||||
| 26 | 12441 | app | 109.98 | |||||
| 27 | 12442 | web | 189.00 | |||||
| 28 | 12444 | marketplace | 971.92 | |||||
| 29 | 12445 | web | 113.92 | |||||
| 30 | 12447 | app | 694.92 | |||||
| 31 | ||||||||
| 32 |
Loading the editor…
Reference solution
Mote checks your result
Press Check. Each right cell becomes a firefly in your lantern.
What Andrew gets, and why
The lesson
SUM adds every number in a range. Most business questions are narrower: revenue from the
app, orders over $100, returns marked damaged. The conditional functions add a test:
they look at one column, keep the rows that pass, and count or add up only those. You met
COUNTIF in the last level with numbers; here the test is on text, and SUMIF adds up money.
COUNTIF: how many rows match
=COUNTIF(range, criteria)
range is the column you test, criteria is what a cell must equal to be counted. On this sheet
the channels are in B2:B30, so:
=COUNTIF(B2:B30,"app")
returns 17: seventeen of Sunday’s 29 completed orders came through the app. The match ignores
case, so "App" and "APP" give the same 17.
SUMIF: add up the matching rows
=SUMIF(range, criteria, sum_range)
SUMIF tests range exactly like COUNTIF, then adds the cells of sum_range that sit on the
matching rows. To add up the app subtotals:
=SUMIF(B2:B30,"app",C2:C30)
Excel pairs the ranges by position: the 1st cell of B2:B30 with the 1st cell of C2:C30, and
so on. Order 12416 in row 2 is an app order, so its 127.95 is added; order 12419 in row 5 is a web
order, so its 19.19 is not. The total is 8,344.73.
If you leave sum_range out, SUMIF adds the tested cells themselves, which is handy for a
condition on the numbers: =SUMIF(C2:C30,">1000") adds the subtotals above 1,000. The next levels
cover conditions like ">1000".
Put the condition in a cell
Andrew wants to switch channels. So instead of typing "app" into both formulas, point at the
input cell G1:
G3 =COUNTIF(B2:B30,G1)
G4 =SUMIF(B2:B30,G1,C2:C30)
A cell reference needs no quotes: the criterion is whatever G1 holds. Type web into G1 and
both answers change to the web orders. Nothing is filled down here, so the $ signs from
chapter 1 are not needed.
Sanity-check the split
A conditional total should fit inside the whole. Two quick checks:
- the counts per channel add up to all the rows: 17 app + 10 web + 2 marketplace = 29 orders, the
29 rows in
A2:A30; G4is below=SUM(C2:C30), and it moves when you changeG1.
If a count comes out 0, look at the data first: a channel stored as app with a trailing space
does not equal app, and COUNTIF will not tell you why.
Common mistakes
- Swapping the ranges in SUMIF. The range you test comes first, the range you add up last.
=SUMIF(C2:C30,G1,B2:B30)returns 0. - Ranges of different sizes.
=SUMIF(B2:B30,G1,C2:C25)pairs the wrong rows or stops early. Make both ranges cover the same rows. - Quotes around a cell reference.
=COUNTIF(B2:B30,"G1")looks for the textG1and finds nothing. - Typing the channel into the formula. It works today, and Andrew’s “now do web” means editing every formula.
Lantern lit!
Practised: countifsumifcriteriaconditional aggregates
- Solved
- No hints
- First run
