1. Lighthouse

Level 3 · Several conditions with SUMIFS and COUNTIFS

The request

From Susan Diaz, Growth Marketer

“Black Friday numbers for the app, please. Only completed orders: cancelled and refunded ones never turned into money. I need the count, the revenue and the average order value. Channel and status are in G1 and G2.”

Your goal

Using the channel in G1 and the status in G2: in G4, count the orders that match both with COUNTIFS; in G5, add up their subtotals (D2:D57) with SUMIFS; in G6, average their subtotals with AVERAGEIFS. Channels are in B2:B57, statuses in C2:C57.

  • Fill G4:G6 with the right valuesnot done yet
  • With formulas, not typed numbersnot done yet
  • Use COUNTIFS SUMIFS AVERAGEIFSnot done yet

Your sheet

Excel
The sheet for this level
ABCDEFGH
1order_idchannelstatussubtotalChannelapp
212059apprefunded424.46Statuscompleted
312060appcompleted119.94
412061webcompleted8.99Orders
512062webcompleted339.86Revenue
612063appcompleted132.97Average order
712064appcompleted2002.88
812065appcompleted136.95
912066appcompleted26.99
1012067webcompleted478.96
1112068marketplacecompleted91.96
1212069appcompleted25.99
1312070appcompleted63.73
1412071appcompleted24.74
1512072appcompleted323.95
1612073webcompleted227.95
1712074appcompleted84.98
1812075appcompleted613.43
1912076appcompleted1152.73
2012077apprefunded188.98
2112078appcompleted27.98
2212079webcompleted52.99
2312080appcompleted40.49
2412081appcompleted60.99
2512082webcompleted100.48
2612083marketplacecompleted313.96
2712084appcompleted17.99
2812085webcompleted1754.97
2912086marketplacecompleted183.99
3012087appcompleted317.92
3112088appcompleted14.24
3212089appcompleted1240.94
3312090webcompleted69.74
3412091webcompleted129.99
3512092appcompleted33.74
3612093webcompleted97.49
3712094webcompleted976.31
3812095appcancelled63.98
3912096appcompleted91.49
4012097webcompleted28.99
4112098marketplacecompleted1221.00
4212099appcompleted21.74
4312100webcompleted339.97
4412101appcompleted116.98
4512102marketplacecompleted399.97
4612103marketplacecompleted125.99
4712104appcompleted34.49
4812105marketplacecompleted31.98
4912106apprefunded263.24
5012107webcompleted1062.81
5112108marketplacecompleted29.99
5212109webcompleted224.98
5312110appcancelled252.71
5412111marketplacecompleted289.00
5512112appcompleted159.74
5612113appcompleted86.97
5712114appcompleted418.49
58
59

Loading the editor…

    ResultPress Check to compare G4:G6

    Mote checks your result

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

    The lesson

    SUMIF takes one condition. Susan’s question has two: the app and completed. For that you use the plural versions, COUNTIFS, SUMIFS and AVERAGEIFS, which take as many conditions as you need.

    Conditions come in pairs

    Every condition is a pair of arguments: a range to test, then what it must match.

    =COUNTIFS(B2:B57,"app",C2:C57,"completed")

    reads as “count the rows where B is app and C is completed”. Excel checks the pairs row by row: row 2 passes only if B2 is app and C2 is completed. On Black Friday that is 27 orders. Add a third pair and a row must pass three tests. The ranges must all have the same size, or the formula returns #VALUE!.

    SUMIFS puts the sum range first

    =SUMIFS(sum_range, range1, criteria1, range2, criteria2, …)

    This is the trap of the whole family. SUMIF has the range to add up last; SUMIFS has it first, so the pairs can go on as long as needed:

    Function Arguments
    SUMIF range, criteria, sum_range
    SUMIFS sum_range, range1, criteria1, …
    AVERAGEIFS average_range, range1, criteria1, …
    COUNTIFS range1, criteria1, … (nothing to add up)

    With the inputs in G1 and G2:

    G4   =COUNTIFS(B2:B57,G1,C2:C57,G2)
    G5   =SUMIFS(D2:D57,B2:B57,G1,C2:C57,G2)
    G6   =AVERAGEIFS(D2:D57,B2:B57,G1,C2:C57,G2)

    G5 shows 7,393.47 and G6 273.83. SUMIFS with a single pair does the same job as SUMIF, so many analysts use only the S versions: one argument order to remember.

    What the status test changes

    Leave the status out and the app looks better than it was. =COUNTIF(B2:B57,G1) counts 32 app orders, and =SUMIF(B2:B57,G1,D2:D57) adds up to 8,586.84. The extra 5 orders are 2 cancelled and 3 refunded ones: 1,193.37 that the store never kept. A dashboard that reports the bigger number overstates Black Friday app revenue by about 16%.

    Check the average by hand

    An average is a sum divided by a count, so G6 should equal G5/G4: 7,393.47 / 27 = 273.83. If they differ, the two formulas are not testing the same rows. AVERAGEIFS returns #DIV/0! when no row matches, for example after a typo such as complete in G2. That error is useful: it tells you the filter found nothing, where SUMIFS would quietly show 0.

    Common mistakes

    • SUMIF order in SUMIFS. =SUMIFS(B2:B57,G1,D2:D57,…) tests the wrong columns. In the S versions the sum range is always first.
    • OR instead of AND. SUMIFS only does AND. For “app or web”, add two of them: =SUMIFS(D2:D57,B2:B57,"app")+SUMIFS(D2:D57,B2:B57,"web").
    • Ranges that don’t line up. B2:B57 with C3:C58 compares each channel with the next row’s status. Same first row, same last row.
    • Averaging the average. The average order value is total revenue over the number of orders, not an average of daily averages.

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