1. Lighthouse

Level 2 · App orders with COUNTIF and SUMIF

The request

From Andrew Ramos, Marketing Manager

“We sent an app push notification on Sunday, December 7. Before I report on it: how many completed orders came through the app that day, and how much revenue? I might ask for web next, so keep the channel in a cell I can change.”

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:G4 with the right valuesnot done yet
  • With formulas, not typed numbersnot done yet
  • Use COUNTIF SUMIFnot done yet

Your sheet

Excel
The sheet for this level
ABCDEFGH
1order_idchannelsubtotalChannelapp
212416app127.95
312417app682.96Orders
412418app37.98Revenue
512419web19.19
612420app51.99
712421web119.96
812422web189.94
912423app286.98
1012424marketplace57.96
1112425web3476.00
1212426web789.95
1312427app443.97
1412428app189.98
1512429app1599.00
1612430web809.92
1712432app139.17
1812433web258.99
1912434web18.99
2012435app11.99
2112436app104.99
2212437app177.94
2312438app13.99
2412439app1737.99
2512440app1932.95
2612441app109.98
2712442web189.00
2812444marketplace971.92
2912445web113.92
3012447app694.92
31
32

Loading the editor…

    ResultPress Check to compare G3:G4

    Mote checks your result

    Press Check. Each right cell becomes a firefly in your lantern.

    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;
    • G4 is below =SUM(C2:C30), and it moves when you change G1.

    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 text G1 and finds nothing.
    • Typing the channel into the formula. It works today, and Andrew’s “now do web” means editing every formula.

    Pick what may run on this site. You can change this any time from "Cookie settings" at the bottom of every page.