02 · Formulas & Functions Basics¶
Every formula starts with =. This module covers writing your own
arithmetic formulas, using built-in functions like SUM and AVERAGE,
and the single most important habit in all of Excel: knowing when a cell
reference should shift as you copy it (relative) and when it must stay
locked (absolute). We'll keep using the budget table from Module 1.
1. Your first formula¶
- Open
budget-tracker.xlsxfrom Module 1. In cellD1, typeDifferenceas a header. - In
D2, type=C2-B2and press Enter. The cell displays0— Actual (1200) minus Budgeted (1200) for Rent. - Every formula is just
=followed by an expression: cell references, numbers, and operators (+,-,*,/,^for exponents). Excel follows standard order of operations — multiplication/division before addition/subtraction — and parentheses()override that order. - Click
D2again and look at the Formula Bar — it shows=C2-B2, the formula, while the cell itself shows0, the calculated result. This distinction (stored formula vs. displayed value) matters constantly.
2. Copying formulas with the fill handle¶
- Select
D2, grab its fill handle (bottom-right corner square), and drag down toD6. - Check
D3: it shows55, and its formula (Formula Bar) reads=C3-B3— not=C2-B2. Excel shifted the references down one row automatically because they were relative references. - The completed column should read: Rent
0, Groceries55, Transport-20, Entertainment75, Savings0— each Actual minus its own Budgeted. - This auto-shifting is what makes the fill handle useful at all — one formula, written once, correctly adapts to every row it's copied into.
3. SUM and AVERAGE¶
- In
A8, typeTotal. InB8, type=SUM(B2:B6)and press Enter — it returns2150, the sum of all five Budgeted values. - Copy
B8across toC8(fill handle, drag right one cell).C8shows=SUM(C2:C6)and evaluates to2260, the sum of Actual values. - In
A9, typeAverage. InB9, type=AVERAGE(B2:B6)— returns430. InC9,=AVERAGE(C2:C6)returns452. - A function call is always
FUNCTIONNAME(arguments).SUMandAVERAGEboth accept one or more ranges or individual cells, comma-separated —=SUM(B2:B4,B6)would sum four of the five rows, skippingB5. MAX(B2:B6)andMIN(B2:B6)return the largest and smallest values in a range (1200and100for the Budgeted column) — useful for a quick sanity check that no value is wildly out of range.COUNT(B2:B6)returns5, the number of cells in the range that contain numbers.
4. Relative vs. absolute references¶
- In
E1, type% of Budget. InE2, type=B2/$B$8and press Enter — this returns roughly55.8%(format the cell as a percentage: Home > Number Format > Percentage, or Ctrl/⌘+Shift+5). - The
$before both the column letter and row number in$B$8makes it an absolute reference — it will not shift when copied.B2(no$) stays relative and shifts normally. - Copy
E2down toE6. CheckE3's formula: it reads=B3/$B$8— the numerator shifted toB3(relative), but the denominator stayed locked at$B$8(absolute), because every row's percentage needs to divide by the same total, not a shifting one. - Without the
$, copying=B2/B8down to row 3 would produce=B3/B9— dividing by an empty cell, since the total only lives inB8. This is the single most common formula bug in Excel; when a copied formula suddenly returns0or#DIV/0!, a missing$on the intended fixed cell is the first thing to check. - A mixed reference locks only the row (
B$8) or only the column ($B8) — useful when copying a formula both across and down a grid where one axis should shift and the other shouldn't. Press F4 (Fn+F4 on some Mac keyboards) while a reference is selected in the Formula Bar to cycle throughB8→$B$8→B$8→$B8→B8without retyping the$signs manually. - The five percentages read: Rent
55.8%, Groceries18.6%, Transport7.0%, Entertainment4.7%, Savings14.0%— they sum to approximately100%(rounding on each displayed percentage means the sum can land a tenth of a point off, e.g.100.1%, which is expected and not an error).
Cheat sheet¶
| Function/Syntax | Purpose | Example |
|---|---|---|
=A1-B1 |
Basic arithmetic formula | =C2-B2 → difference |
SUM(range) |
Add all values in a range | =SUM(B2:B6) → 2150 |
AVERAGE(range) |
Mean of values in a range | =AVERAGE(C2:C6) → 452 |
MAX(range) / MIN(range) |
Largest / smallest value | =MAX(C2:C6) → 1200 |
COUNT(range) |
Count of numeric cells | =COUNT(B2:B6) → 5 |
A1 |
Relative reference — shifts when copied | |
$A$1 |
Absolute reference — never shifts | |
$A1 / A$1 |
Mixed reference — column or row locked | |
| F4 | Cycle reference type in Formula Bar |
How It Actually Works¶
When you press Enter after typing a formula, Excel doesn't just compute a
value once — it parses the formula text into a small tree of operations and
cell references, and registers that cell as a dependent of every cell it
references inside its internal dependency graph. This graph is what makes
recalculation fast: changing B2 doesn't force Excel to re-evaluate every
formula in the workbook, only the ones reachable by walking outward from
B2 through the dependency edges, in an order that guarantees each cell is
recalculated only after everything it depends on already has its final
value (a topological sort of the graph). Relative references like B2
are stored not as a fixed address but as an offset from the formula's own
cell — copying a formula down a column re-applies that offset from each new
position, which is why the row number shifts. An absolute reference ($B$2)
stores a fixed coordinate instead of an offset, so copying it never
changes it. If the graph ever contains a cycle — a formula that depends,
directly or through a chain, on itself — Excel can't produce a valid
evaluation order and flags it as a circular reference rather than looping
forever.
Exercise¶
In budget-tracker.xlsx, add a Difference column (=C2-B2, copied down),
a Total row using SUM for both Budgeted and Actual, an Average row
using AVERAGE for both, and a % of Budget column using an absolute
reference to the Budgeted total so it doesn't break when copied down.
Confirm the Budgeted total is 2150, the Actual total is 2260, and the
% of Budget column sums to approximately 100%.