Excel Supreme

Excel track · Exercise 56 of 86 Paid

Capstone: North gross margin

Total by region, divide to a margin percentage, and leave a blank where revenue is missing.

Advanced

Revenue and cost by region

Read-only data · screen 1 of 2 · answer in B7

In B7, work out the North gross margin as a percentage, rounded to 1 decimal, and wrap it in IFERROR so an empty region shows a blank.

ABC
1RegionRevenueCost
2North1500800
3South1200900
4North1000580
5West900700
6
7North gross margin %

Download this grid (.xlsx) Two tabs: the grid you see, and the answer.

B7

What it does

SUMIF pulls the North rows out of each money column: revenue 1500 + 1000 comes to 2500 and cost 800 + 580 to 1380. Subtracting cost from revenue leaves 1120, and dividing that by revenue gives 0.448. Multiply by 100 and ROUND to one decimal for 44.8.

The reference answer nests three functions. SUMIF builds both totals, ROUND holds the margin at one decimal, and IFERROR wraps the result. A region with no revenue would divide by zero, and IFERROR(value,"") turns that error into a blank a chart can still plot.

Order inside the nest matters. ROUND sits inside IFERROR, so the guard wraps a finished number. Swapped, an empty region's division error reaches the cell before IFERROR can answer. Leave ROUND out and the margin arrives with a long tail of digits.

Syntax

=IFERROR(ROUND((SUMIF(regions,"North",revenue)-SUMIF(regions,"North",cost))/SUMIF(regions,"North",revenue)*100,1),"")

Worked example

On Revenue and cost by region, =IFERROR(ROUND((SUMIF(A2:A5,"North",B2:B5)-SUMIF(A2:A5,"North",C2:C5))/SUMIF(A2:A5,"North",B2:B5)*100,1),"") returns 44.8.

=IFERROR(ROUND((SUMIF(A2:A5,"North",B2:B5)-SUMIF(A2:A5,"North",C2:C5))/SUMIF(A2:A5,"North",B2:B5)*100,1),"")

Common errors

Error codes for SUMIF, ROUND and IFERROR nested in one formula
ErrorWhat it means and how to fix it
#DIV/0!A region with no revenue divides by zero, so the cell shows this until IFERROR catches it.
#NAME?North is typed without quotes, so Excel reads it as a name and returns #NAME?.
40 for 44.8Rounding the ratio to one decimal before multiplying by 100 gives 40 instead of 44.8.

At work

The region summary cell: two SUMIF totals, a ratio, a rounded figure and a blank where a region has no revenue.