How can a spreadsheet make decisions and look up values from a table?
Use the IF function for conditional results and lookup functions such as VLOOKUP to find values in a table
A focused answer to the O-Level Computing point on logical and lookup functions. Using IF for conditional results, nesting IF for grades, and VLOOKUP to find a matching value in a table.
Reviewed by: AI editorial process; not yet individually human-reviewed
Have a quick question? Jump to the Q&A page
Jump to a section
What this dot point is asking
SEAB wants you to use the IF function to produce a result that depends on a condition, and to use a lookup function such as VLOOKUP to find a value in a table. The central idea is that IF lets a spreadsheet make a decision, while a lookup function lets it find a matching entry automatically rather than searching by eye.
The answer
The IF function
The IF function chooses between two results based on a condition. It takes three parts:
=IF(condition, value_if_true, value_if_false)
The condition is usually a comparison such as B2>=50. If it is true, the function returns the first value; if false, it returns the second.
=IF(B2>=50, "Pass", "Fail")
Text results are written in quotation marks; numbers are not.
Comparison operators
IF conditions use comparison operators: = (equal to), > (greater than), < (less than), >= (greater than or equal to), <= (less than or equal to) and <> (not equal to).
Nesting IF for more than two outcomes
For three or more outcomes, put another IF in the false part. The conditions are checked from the outside in:
=IF(B2>=70, "Distinction", IF(B2>=50, "Pass", "Fail"))
Order matters: check the highest band first, so a mark of is caught by >=70 and never reaches the lower tests.
The VLOOKUP function
VLOOKUP (vertical lookup) finds a value in the first column of a table and returns a value from another column in the same row. It takes four parts:
=VLOOKUP(value, table, column_number, FALSE)
- value: what to search for.
- table: the range holding the data.
- column_number: which column of the table to return (counting from on the left).
- FALSE: asks for an exact match.
=VLOOKUP(D2, A2:B5, 2, FALSE)
VLOOKUP always searches the leftmost column of the table, so the value you look up must sit in that first column.
Examples in context
Example 1. Awarding grades. A teacher uses a nested IF on each student's mark to display A, B, C or F automatically. When marks are entered, the grade column fills itself, and a change to a mark updates the grade instantly.
Example 2. A price list at a counter. A cafe stores item prices in a lookup table and uses VLOOKUP so that typing an item code shows its price. Staff never search the list by eye, and updating a price in the table updates every sale that looks it up.
Try this
Q1. Write an IF function in B2 that shows "Yes" if A2 is greater than , otherwise "No". [2 marks]
- Cue.
=IF(A2>100, "Yes", "No").
Q2. In =VLOOKUP(D2, A2:C10, 3, FALSE), state which column's value is returned. [2 marks]
- Cue. The third column of the table range (column C), the column counted as from the left.
Q3. Explain why the search value for VLOOKUP must be in the first column of the table. [2 marks]
- Cue. VLOOKUP only searches the leftmost column for the value, then counts columns to the right to return the result.
Exam-style practice questions
Practice questions written in the style of SEAB exam questions on this dot point, with worked answer explainers. The year tag is the paper they imitate, not the source.
Original5 marksA mark is in cell B2. (a) Write an IF function in C2 that displays 'Pass' if the mark is or more, and 'Fail' otherwise. (b) Extend the idea to show 'Distinction' for or more, 'Pass' for to , and 'Fail' below , by nesting IF functions.Show worked answer →
(a) The IF function takes a condition, a value if true, and a value if false:
=IF(B2>=50, "Pass", "Fail")
(b) Nest a second IF inside the false part to handle three bands:
=IF(B2>=70, "Distinction", IF(B2>=50, "Pass", "Fail"))
The outer IF checks first; if false, the inner IF checks ; if that is also false, the result is "Fail".
Markers reward the correct IF structure (condition, true value, false value), the boundary , and a correctly nested IF for the three bands.
Original5 marksA table in cells A2:B5 lists product codes in column A and prices in column B. A code is entered in cell D2. (a) Write a VLOOKUP function in E2 to find the matching price. (b) Explain why the lookup column must be the leftmost column of the table.Show worked answer →
(a) VLOOKUP searches the first column of a table for the value, then returns a value from another column in the same row:
=VLOOKUP(D2, A2:B5, 2, FALSE)
D2 is the value to find, A2:B5 is the table, is the column to return (the price), and FALSE asks for an exact match.
(b) VLOOKUP always searches the leftmost column of the table range for the lookup value. So the product code, which is what we search for, must be in the first column; the price we want to return is then found by counting columns to the right.
Markers reward the VLOOKUP arguments (value, table, column number, exact match) and the reason that VLOOKUP only searches the first column.
Related dot points
- Describe how a spreadsheet is organised into cells, rows and columns, and write formulae using cell references and operators
A focused answer to the O-Level Computing point on spreadsheet basics. Cells, rows and columns, cell references, writing formulae with operators, and why formulae recalculate automatically when data changes.
- Distinguish relative and absolute cell references, use the dollar sign to fix a reference, and predict how references change when a formula is copied
A focused answer to the O-Level Computing point on cell references. How relative references change when copied, how absolute references with a dollar sign stay fixed, and how to predict the result of copying a formula.
- Use common spreadsheet functions (SUM, AVERAGE, MAX, MIN, COUNT) with cell ranges to summarise data
A focused answer to the O-Level Computing point on spreadsheet functions. Using SUM, AVERAGE, MAX, MIN and COUNT with cell ranges to summarise data, and the colon range notation.
- Choose an appropriate chart type for data, and use sorting and filtering to organise and find records
A focused answer to the O-Level Computing point on presenting data. Choosing a suitable chart (bar, line, pie), sorting records into order, and filtering to show only the rows that meet a condition.
- Use Python selection with if, elif and else, build conditions with comparison and logical operators, and order branches correctly
A focused answer to the O-Level Computing point on Python selection. Using if, elif and else, comparison operators, combining conditions with and, or and not, and ordering branches so each value falls into the right one.