Spreadsheet Formulas
Theory
A spreadsheet formula starts with = and uses cell references such as B2 in place of numbers, so the answer updates when the data changes. This Year 11 Standard maths page covers reading and writing formulas, * and /, order of operations and brackets, filling a formula down, the SUM, AVERAGE, MEDIAN, MAX, MIN and STDEV.P functions, percentages, and finding a wrong or missing value.
A spreadsheet is a grid of cells. Columns are named by letters (A, B, C, …) and rows by numbers (1, 2, 3, …). A cell reference gives the column letter first, then the row number: C4 is the cell in column C, row 4.
A formula always starts with an equals sign. It can use numbers, cell references and the operators +, −, * (multiply) and / (divide). The cell shows the value the formula calculates, not the formula itself. For example, if B1 holds \(15\) and B2 holds \(4\), a cell containing =B1*B2 displays \(60\).
A range such as B2:B6 means every cell from B2 to B6. Functions work on a range: =SUM(B2:B6) adds the five cells, and =AVERAGE(B2:B6) finds their mean.
Filling down copies a formula into the cells below it. The row numbers in the formula change to match each new row, so the same calculation is done on every row.
Spreadsheets follow the usual order of operations: brackets first, then multiplication and division, then addition and subtraction. A formula with a fraction needs brackets around the whole numerator and the whole denominator.
Operators and functions used in our questions:
| In a spreadsheet | Meaning |
|---|---|
| =B2+C2, =B2-C2 | add, subtract |
| =B2*C2 | multiply, \(B2 \times C2\) |
| =B2/C2 | divide, \(\dfrac{B2}{C2}\) |
| =(B2+B3)/(C2+C3) | \(\dfrac{B2+B3}{C2+C3}\): brackets keep the whole top and the whole bottom together |
| =SUM(B2:B6) | total of B2 to B6 |
| =AVERAGE(B2:B6) | mean of B2 to B6 |
| =MEDIAN(B2:B6) | middle value of B2 to B6 when in order |
| =MAX(B2:B6), =MIN(B2:B6) | largest value, smallest value |
| =MAX(B2:B6)-MIN(B2:B6) | range (largest \(-\) smallest) |
| =STDEV.P(B2:B6) | population standard deviation \(\sigma\) |
Percentages are entered as decimals:
For a population standard deviation (what STDEV.P calculates):
Finding the value a formula displays
- Replace each cell reference with the number in that cell.
- Calculate using the order of operations: brackets, then * and /, then + and −.
- State the value with units if the column heading gives them (for example $).
Writing a formula
- Write the calculation in words or as a formula first (pay \(=\) hours \(\times\) rate).
- Swap each quantity for its cell reference, column letter first.
- Start with =, use * and /, and add brackets around any whole numerator or denominator.
- Test it with the numbers in the sheet to see that it gives a sensible value.
Filling down, errors and missing values
- Filling down: move the row number of every reference down by one for each row. Add the same step each row for a formula like =B2+25.
- Finding an error: recalculate each row. A wrong value often matches a different operation (a sum instead of a product).
- Missing value: if you know the value a formula cell displayed (from an earlier printout or a graph made before the change), write the formula as an equation with the unknown cell and solve it.
| A | B | |
|---|---|---|
| 1 | Supply charge ($/day) | 1.10 |
| 2 | Days | 90 |
| 3 | Usage (kWh) | 1250 |
| 4 | Price ($/kWh) | 0.32 |
| 5 | Bill excl. GST ($) | =B1*B2+B3*B4 |
| 6 | Bill incl. GST ($) | =B5*1.1 |
(i) Replace each cell with its value. Both multiplications are done before the addition.
| \(\text{B5}\) | \(=\) | \(1.10 \times 90 + 1250 \times 0.32\) |
| \(\) | \(=\) | \(99 + 400\) |
| \(\) | \(=\) | \(\mathbf{499}\) |
(ii) Multiplying by \(1.1\) adds \(10\%\) GST.
| \(\text{B6}\) | \(=\) | \(499 \times 1.1\) |
| \(\) | \(=\) | \(\mathbf{548.90}\) |
\(\therefore\) B5 displays \(499\) (\(\$499\)) and B6 displays \(548.9\) (\(\$548.90\)).
| A | B | C | D | |
|---|---|---|---|---|
| 1 | Month | Sales ($) | Costs ($) | Profit ($) |
| 2 | Jul | 4200 | 3650 | =B2-C2 |
| 3 | Aug | 3900 | 3480 | |
| 4 | Sep | 4500 | 610 | |
| 5 | Oct | 4100 | 3720 |
(ii) What value was in C4?
(i) Filling down changes the row numbers to match the row: D3 =B3-C3, D4 =B4-C4, D5 =B5-C5.
| \(\text{D5}\) | \(=\) | \(4100 - 3720\) |
| \(\) | \(=\) | \(\mathbf{380}\) |
(ii) D4 contains =B4-C4 and displayed \(610\), so
| \(4500 - \text{C4}\) | \(=\) | \(610\) |
| \(\text{C4}\) | \(=\) | \(4500 - 610\) |
| \(\) | \(=\) | \(\mathbf{3890}\) |
\(\therefore\) D5 is =B5-C5 (displays \(380\)), and C4 held \(3890\) (costs of \(\$3890\)).
(i) =SUM(B2:B7) (ii) =AVERAGE(B2:B7)
(iii) =MEDIAN(B2:B7) (iv) =MAX(B2:B7)-MIN(B2:B7)
(v) =STDEV.P(B2:B7), to two decimal places
(i) \(12 + 7 + 16 + 9 + 14 + 8 = \mathbf{66}\)
(ii) \(\text{mean} = \dfrac{66}{6} = \mathbf{11}\)
(iii) In order: \(7,\ 8,\ 9,\ 12,\ 14,\ 16\). With six values the median is halfway between the 3rd and 4th: \(\dfrac{9 + 12}{2} = \mathbf{10.5}\)
(iv) \(16 - 7 = \mathbf{9}\), the range.
(v) Deviations from the mean \(11\): \(1,\ -4,\ 5,\ -2,\ 3,\ -3\).
| \(\sigma\) | \(=\) | \(\sqrt{\dfrac{1 + 16 + 25 + 4 + 9 + 9}{6}}\) |
| \(\) | \(=\) | \(\sqrt{\dfrac{64}{6}}\) |
| \(\) | \(=\) | \(3.2659\ldots\) |
| \(\) | \(\approx\) | \(\mathbf{3.27}\) |
(i) Which formula should go in C5 to calculate \(S\)?
(ii) What does it display?
(iii) What would =B2+B3/C2+C3 display instead?
(i) Replace each pronumeral with its cell: \(d_1\) is B2, \(d_2\) is B3, \(t_1\) is C2, \(t_2\) is C3. The numerator and the denominator each need brackets.
\(\therefore\) =(B2+B3)/(C2+C3)
(ii)
| \(S\) | \(=\) | \(\dfrac{120 + 90}{2 + 1}\) |
| \(\) | \(=\) | \(\dfrac{210}{3}\) |
| \(\) | \(=\) | \(\mathbf{70}\) |
C5 displays \(70\) (km/h).
(iii) Without brackets only B3 is divided, and only by C2:
| \(\) | \(\) | \(120 + \dfrac{90}{2} + 1\) |
| \(\) | \(=\) | \(120 + 45 + 1\) |
| \(\) | \(=\) | \(166\) |
\(166\) km/h is clearly wrong for a trip of \(210\) km in \(3\) hours: always test a formula with the numbers in the sheet.
Common pitfalls
Frequently asked questions
How do you write a formula in a spreadsheet?
Start with an equals sign, then use cell references in place of the numbers, with * for multiply and / for divide. For example =B2*C2 multiplies the value in B2 by the value in C2.
What does B2:B6 mean in a spreadsheet?
It is a range: every cell from B2 down to B6, which is B2, B3, B4, B5 and B6. Functions such as SUM, AVERAGE and MEDIAN work on a range.
What happens when you fill a formula down?
The row numbers in the formula change to match each new row. If C2 holds =A2*B2, filling down puts =A3*B3 in C3, =A4*B4 in C4, and so on.
Why does my spreadsheet formula give the wrong answer?
The most common reason is missing brackets. A spreadsheet multiplies and divides before it adds and subtracts, so a whole numerator or denominator must go in brackets. Also check that each cell reference points to the right cell.
How do you add a percentage in a spreadsheet?
Write the percentage as a decimal. To find 3% of the value in B2, use =B2*0.03. To increase B2 by 15%, multiply by 1 plus 0.15: =B2*1.15.