F202 TA3: Creating the Spreadsheet Model
Formulas, functions and references
Operators and the order they work in
| Operator | Meaning | Example |
|---|---|---|
+ - * / | Add, subtract, multiply, divide | =Revenue-TotalCosts |
^ | Power | =1.05^3 for three years of 5% growth |
& | Join text | =A2&" tickets" |
= <> < > <= >= | Compare, giving TRUE or FALSE | =Profit>=0 |
Brackets first, then powers, then multiplication and division, then addition and subtraction. =4000+5*270 is 5,350. Write =(4000+5)*270 only if that is what you mean.
Functions worth knowing
| Category | Functions | Example |
|---|---|---|
| Totals and averages | SUM, AVERAGE, MEDIAN, MIN, MAX | =AVERAGE(B2:B31) |
| Counting | COUNT, COUNTA, COUNTBLANK, COUNTIF, COUNTIFS | =COUNTIF(Type,"Child") |
| Conditional totals | SUMIF, SUMIFS, AVERAGEIF, MAXIFS | =SUMIFS(Revenue,Type,"Adult",Day,"Sat") |
| Rounding | ROUND, ROUNDUP, ROUNDDOWN, INT | =ROUNDUP(Visitors/50,0) stewards needed |
| Text | LEFT, RIGHT, MID, LEN, UPPER, TRIM, CONCAT, TEXTJOIN | =UPPER(LEFT(A2,3)) |
| Dates | TODAY, DATE, YEAR, WEEKDAY, NETWORKDAYS | =FestivalDate-TODAY() days to go |
| Logic | IF, IFS, AND, OR, NOT, IFERROR | =IF(AND(Profit>0,TicketsSold<Capacity),"OK","Check") |
| Lookup | XLOOKUP, VLOOKUP, HLOOKUP, INDEX, MATCH | =XLOOKUP(B2,Types,Prices) |
| Finance | PMT, FV | =PMT(6%/12,36,-12000) is about £365 a month |
The festival model, as built
TicketsSold =MIN(Capacity, MAX(0, DemandAtZero - LostPerPound * TicketPrice))
Revenue =TicketsSold * TicketPrice
VariableCosts =TicketsSold * CostPerHead
TotalCosts =FixedCosts + VariableCosts
Profit =Revenue - TotalCosts
Status =IF(Profit >= 0, "PROFIT", "LOSS")
BreakEvenTickets =ROUNDUP(FixedCosts / (TicketPrice - CostPerHead), 0)Every formula refers to a named cell, so it reads as a sentence. MAX(0, …) was not in the original design: test 5 found that a price of £60 gave −120 tickets, and this is the fix. BreakEvenTickets is the classic break-even calculation: at £27.50 the festival needs 4000 ÷ 22.50, rounded up to 178 tickets, to cover its costs.
Tables and structured references
Formatting a list as a table (Ctrl+T in Excel) gives it a name, makes it grow when rows are added, and lets formulas say Sales[Revenue] instead of $D$2:$D$4001. Charts, pivot tables and validation lists built on a table then pick up new rows by themselves.
Inputs first, then each calculation in turn, checking each one by hand before building the next. A wrong value found at step two is a minute's work. Found on the dashboard, it could be anywhere.
Decisions and lookups
IF, and the logic around it
=IF(test, value if true, value if false) chooses between two results.
| Need | Formula |
|---|---|
| One test | =IF(Profit>=0,"PROFIT","LOSS") |
| Both conditions must be true | =IF(AND(Age>=16,Age<=18),"Concession","Standard") |
| Either condition is enough | =IF(OR(Type="Child",Type="Concession"),"Reduced","Full") |
| Several outcomes | A nested IF, or IFS |
Lookups
When the answer comes from a table, a lookup is better than a chain of IFs: the table can be read, checked and changed without touching a formula.
| Function | Use it when | Watch out for |
|---|---|---|
XLOOKUP | You have a current version of Excel or Google Sheets | Older versions do not have it |
VLOOKUP | The value you match is in the first column of the table | Count the column number carefully, and use FALSE for an exact match |
HLOOKUP | The table runs across rows instead of down columns | The same as VLOOKUP |
INDEX with MATCH | It must work in every program, or look to the left | Two functions to get right instead of one |
IFERROR | A lookup might reasonably find nothing | It hides every error, so use it only where you expect one |
=INDEX(Prices, MATCH(B2, Types, 0)) does the same job as the XLOOKUP in the diagram, in any spreadsheet program. The 0 asks MATCH for an exact match.
Validation, formatting, protection and macros
Data validation
- Give each input cell an input message, so the rule is visible before anybody breaks it.
- Choose the error style deliberately. Stop refuses the value. Warning and Information let it through after a message, which suits values that are unusual rather than impossible.
- Feed drop-down lists from a named range, so the list can grow without editing the rule.
Conditional formatting
Formatting that responds to the value: profit in red below zero, a data bar showing tickets sold against capacity, a colour scale across a data table so the best prices stand out. A rule can use a formula, such as =$D2<0 to shade a whole row when its profit is negative.
Use it to draw the eye to what needs attention, and use it sparingly. A sheet where everything is highlighted highlights nothing.
Protection
- Unlock the input cells: Format Cells, Protection, untick Locked. Every cell starts locked.
- Protect the sheet, so that only the unlocked cells can be edited.
- Protect the workbook structure, so sheets cannot be deleted, moved or renamed.
- Record any password in the technical documentation, not in the user guide.
Sheet protection prevents accidents, not determined people, and its passwords can be removed. Confidential data needs an encrypted file and proper access control, not a protected sheet.
Macros
A macro records or codes a sequence of actions so it can be run with one click. Typical uses in a model: run Goal Seek, reset the inputs to their defaults, clear a form, print the dashboard, or move between sheets.
' Finds the ticket price that gives the target profit typed on the dashboard
Sub FindPriceForTarget()
Range("Profit").GoalSeek Goal:=Range("TargetProfit").Value, _
ChangingCell:=Range("TicketPrice")
End Sub- In Excel, macros are written in VBA, and the file must be saved as
.xlsm. Google Sheets uses Apps Script instead, and LibreOffice uses Basic. - Assign each macro to a clearly labelled button, and test it like any other feature.
- Users see a security warning when they open a file containing macros, so the user guide has to tell them what to do.
What-if analysis
What-if analysis is the reason a model exists. There are four ways to do it, and each answers a different kind of question.
| Tool | The question it answers | Where it is in Excel |
|---|---|---|
| Changing an input | What happens if the price is £30? | Type a new value |
| Goal Seek | What price gives a £1,000 profit? | Data, What-If Analysis, Goal Seek |
| Scenario Manager | How do the pessimistic, expected and optimistic cases compare? | Data, What-If Analysis, Scenario Manager |
| Data table | What is the profit at every price from £10 to £50? | Data, What-If Analysis, Data Table |
LibreOffice Calc has the same tools under different names: Goal Seek and Scenarios on the Tools menu, and Multiple Operations for data tables. Google Sheets has no built-in Scenario Manager or data table, so there the grid of results is built with ordinary formulas.
What-if model
Change the inputs of a spreadsheet model and watch every output, the break-even prices and the graph recalculate. This tool needs JavaScript, so turn it on to use it. Everything you need to answer the exam question is explained in the text above.
The chart shows what a single answer cannot. The best price is £27.50, but the curve is flat near the top: £25 and £30 both make £2,000, only £75 less, so the committee can choose a round price and lose very little. Below £16.67 the festival sells out, so lowering the price further only gives money away. And £20 and £35 make the same profit, but £35 does it with half the crowd.
Sensitivity analysis
Change each assumption by the same amount, 10% here, and see how far the profit moves.
| Assumption changed by 10% | Profit at £27.50 | Change |
|---|---|---|
| None: the expected case | £2,075 | — |
| Demand at £0 falls from 600 to 540 | £725 | −£1,350 |
| Fixed costs rise from £4,000 to £4,400 | £1,675 | −£400 |
| Cost per head rises from £5.00 to £5.50 | £1,940 | −£135 |
The model is far more sensitive to the demand assumption than to either cost, so the survey behind it deserves the closest checking, and the evaluation should say so.
For harder questions, such as the most profitable price that still sells at least 300 tickets, Excel's Solver add-in and LibreOffice's Solver find the best value of an output while keeping to constraints you set.
Charts and pivot tables
Choosing the chart
- A line or scatter chart shows one quantity against another, such as profit against price.
- A column or bar chart compares categories, such as tickets by type or profit by scenario.
- A pie chart shows parts of a whole, and only works with a few slices.
- Every chart needs a title, axis titles with units, and a legend only if there is more than one series.
- Start a column chart's axis at zero, or the differences look bigger than they are.
- Build charts from tables or named ranges, so they update when the data grows.
Pivot tables
A pivot table is the quickest way to explore a long list: drag fields into rows, columns and values, and change the view in seconds. For figures the client relies on, formulas such as SUMIFS are safer, because they always recalculate.
Sources and further reading
- Microsoft Excel help and learning: functions, Goal Seek, Scenario Manager, data tables, validation, protection and macros, each with worked examples.
- Google Sheets function list: every function in Sheets, including XLOOKUP and the IF family.
- LibreOffice Help: Calc's Goal Seek, Scenarios, Multiple Operations and Solver.
- GCF Global Excel tutorials: free lessons on functions, charts, pivot tables and what-if analysis.
- The what-if model on its own page: the interactive model above, with room to explore.
Key terms you must be able to define
- Formula
- A calculation written by the user, starting with an equals sign.
- Function
- A built-in calculation, such as SUM, IF or XLOOKUP.
- Nested IF
- An IF function placed inside another, to choose between more than two outcomes.
- Lookup
- A function that finds a value in a table, such as XLOOKUP or VLOOKUP.
- Exact match
- A lookup that returns a result only when the value is found exactly.
- Approximate match
- A lookup that returns the largest value not greater than the one searched for, in a sorted table.
- Data validation
- Rules restricting what can be entered into a cell.
- Input message
- A note shown when a validated cell is selected, explaining what to enter.
- Conditional formatting
- Formatting applied automatically when a cell's value meets a rule.
- Cell protection
- Locking cells and protecting the sheet so that only unlocked cells can be edited.
- Macro
- A recorded or coded sequence of actions that runs with one command.
- Goal Seek
- A tool that changes one input cell until a formula cell reaches a target value.
- Scenario Manager
- A tool that stores named sets of inputs and compares their outputs.
- Data table
- A grid showing a formula's result for a range of values of one or two inputs.
- Pivot table
- An interactive summary of a list, grouping and totalling it without formulas.
Flashcards
Reach the top grade on this topic
- Refer to named cells, never to typed numbers, so every formula reads as a sentence
- Use the right tool for each job: a lookup for a table, IF for a decision, validation for an input
- Validate every input, with input messages and a deliberate choice of error style
- Protect the formulas and leave only the inputs editable
- Use what-if tools to answer the client's question, and explain what each result means
- Show a range of techniques used well, each one justified by a requirement
Mistakes that cost marks here
- Typing values into formulas, so changing an assumption means hunting through every cell.
- VLOOKUP without FALSE, which silently returns approximate matches.
- Nested IFs that test the smallest threshold first, so the larger bands are never reached.
- Protecting the sheet before unlocking the input cells, so nobody can enter anything.
- Running Goal Seek once and reporting the answer without checking it in the model.
- Charts with no axis titles or units.
- Using IFERROR to hide errors that should have been fixed.
Excel stores dates as numbers counting days from 1 January 1900, and it treats 1900 as a leap year, which it was not. The error was copied on purpose from an older spreadsheet, Lotus 1-2-3, so that old files would still give the same answers.
Knowledge check
Check you could explain this
- LValidation restricts what can be entered, such as a range or a type
- LSo invalid data is rejected before it reaches the calculations
- LProtection locks formula cells so they cannot be overwritten
- LTogether, only valid data goes in, and only in the right places
Data validation restricts what each input cell will accept, for example a decimal from 5 to 60 for a ticket price or a choice from a list for a ticket type, so invalid or wrongly typed data is rejected before it can reach any calculation. Cell protection locks every formula cell and protects the sheet, so a user cannot type over a formula by accident, which would replace a calculation with a fixed number and break the model without any warning. Together they mean that data can only be entered in the input cells, and only valid data at that, which removes the two most common ways a working model is broken by its users.
- LGoal Seek works backwards from a target output to an input
- LGoal Seek changes only one input and finds one answer
- LScenario Manager stores several named sets of input values
- LScenario Manager compares the outputs of the scenarios, such as in a summary
Goal Seek works backwards: you give it a target for one formula cell, such as a profit of 1,000 pounds, and it changes a single input cell, such as the price, until the target is reached. It answers 'what input do I need?', but it only changes one value and finds one answer, which depends on where it started. Scenario Manager works forwards with several inputs at once: it stores named sets of values, such as pessimistic, expected and optimistic, and produces a summary comparing their outputs side by side. It answers 'what range of results might we see?', which makes it the better tool for judging risk, while Goal Seek is the better tool for setting a target.
- LThe fourth argument is missing, so VLOOKUP makes an approximate match
- LApproximate matching needs a sorted table and returns the nearest lower value
- LIt always returns something, so no error appears
- LFix: add FALSE, or use XLOOKUP or INDEX with MATCH
- LRetest every ticket type, and handle values not found
The formula leaves out VLOOKUP's fourth argument, and when it is missing VLOOKUP does an approximate match. Approximate matching assumes the first column is sorted and returns the row with the largest value not greater than the one searched for, so with an unsorted list of ticket type names it can land on the wrong row. Because an approximate match always returns something, there is no error to warn anyone, and the wrong price looks perfectly believable. The fix is to ask for an exact match, =VLOOKUP(B2,Tickets,2,FALSE), or to use =XLOOKUP(B2,Tickets[Type],Tickets[Price]), which matches exactly by default. The lookup should then be retested with every ticket type and with a value that is not in the table, which should now give #N/A, handled with IFERROR and a clear message for the user.