IF, IFS, AND, OR and IFERROR
IF turns a rule, such as "flag orders over 500", into a formula. AND, OR and IFERROR build on it.
- LearnRead the guide and its worked examples.
- PractiseA drill on just this skill, easier tasks first. Stuck? “Show me how”.
- TestA timed mock in the style your employer named.
- ReviewYour report shows what cost marks and what to practise next.
The functions
- IF
=IF(test, value_if_true, value_if_false) - Checks a test. Shows the first value if it is true, the second if not.
- IFS
=IFS(test1, value1, test2, value2, ...) - Checks tests in order and shows the value for the first one that is true.
- AND
=AND(test1, test2, ...) - TRUE only if every test is true.
- OR
=OR(test1, test2, ...) - TRUE if at least one test is true.
- IFERROR
=IFERROR(formula, value_if_error) - Shows the formula's result, or your chosen value if the formula gives an error.
Worked examples
Example 1 Did each rep hit target?
| A | B | C | D | |
|---|---|---|---|---|
| 1 | Rep | Sales | Target | Result |
| 2 | Amy | 5,200 | 5,000 | Met |
| 3 | Ben | 4,700 | 5,000 |
=IF(B2>=C2,"Met","Not met") and shows Met (highlighted).Piece by piece
IF(- Check something and choose what to show.
B2>=C2- The test: are sales greater than or equal to the target? 5200 is, so it is TRUE.
"Met"- Shown when the test is TRUE. Text goes in double quotes.
"Not met"- Shown when the test is FALSE. Ben's row would show this.
Example 2 Bonus only if two rules are both met
| A | B | C | D | |
|---|---|---|---|---|
| 1 | Rep | Sales | Days off | Bonus? |
| 2 | Cara | 6,100 | 3 | No bonus |
| 3 | Dev | 5,400 | 1 |
=IF(AND(B2>=5000,C2<=2),"Bonus","No bonus") and shows No bonus (highlighted).Piece by piece
AND(- Both tests inside must be true.
B2>=5000- Sales of at least 5000. Cara's 6100 passes.
C2<=2- Two days off or fewer. Cara had 3, so this fails.
IF(AND(...), ...)- One test failed, so AND is FALSE and IF shows "No bonus". Dev's row would show "Bonus".
Example 3 Hide a divide-by-zero error
| A | B | C | D | |
|---|---|---|---|---|
| 1 | Shop | Visitors | Sales | Rate |
| 2 | High St | 0 | 0 | n/a |
| 3 | Market Sq | 250 | 40 |
=IFERROR(C2/B2,"n/a") and shows n/a (highlighted).Piece by piece
C2/B2- Sales divided by visitors. With 0 visitors this is #DIV/0!.
IFERROR(...,- If the sum inside gives an error, show something else.
"n/a"- What to show instead of the error. On the next row the rate works out normally: 0.16.
Common mistakes
- Forgetting the double quotes around text, such as "Met". Without them you get #NAME?.
- Using > when the rule says "at least". "At least 5000" is >=5000.
- Putting quotes around numbers: "5000" is text, not a number, and the test may never be true.
- Wrapping everything in IFERROR. It hides real mistakes too, so use it only where an error is expected.
Excel and Google Sheets
In Excel: IFS needs Excel 2019 or Microsoft 365. In older versions, nest IFs: =IF(A2>=90,"A",IF(A2>=70,"B","C")).
In Google Sheets: IF, IFS, AND, OR and IFERROR work the same way. Google Sheets shows a tooltip with each argument as you type.
Now practise it
Reading gets you started; doing it under a clock is what the test checks. Practise this skill on its own, easier tasks first, then take a mock.
Practise in the Excel style Practise in the Google Sheets style
Skill drills come with the 30-day and 90-day passes. No pass yet? Try the free five-task mini-mock, no account needed.