Excel IF Function: Pass or Fail in One Formula
You have a list of names and marks, and someone wants a column that says "Pass" or "Fail". You could type it by hand. Or you could write one formula, copy it down, and let Excel do the sorting for you.
By the end of this post you'll be able to use the Excel IF function to label results automatically, add a second rule with AND or OR, and handle three or more outcomes with a nested IF or IFS. We'll use a 50% pass mark on a workplace training assessment, because that's a cut-off most people recognise.
How the Excel IF function works
IF asks a yes-or-no question and gives back one of two answers. It has three parts:
=IF(test, value_if_true, value_if_false)
- test: something that is either TRUE or FALSE, such as
B2>=50 - value_if_true: what to show when the test is TRUE
- value_if_false: what to show when it's FALSE
Read it out loud like a sentence: "If B2 is at least 50, show Pass, otherwise show Fail." If you can say your rule that way, you can write it as an IF.
Step 1: Write the test first
Every IF starts with a comparison. Before you wrap it in IF, try the comparison on its own. Type =B2>=50 in an empty cell and Excel answers TRUE or FALSE. That's your test, working.
These are the comparison operators you'll use most:
| Operator | Meaning | Example | Result when B2 is 50 |
|---|---|---|---|
= |
equal to | =B2=50 |
TRUE |
<> |
not equal to | =B2<>50 |
FALSE |
> |
greater than | =B2>50 |
FALSE |
>= |
greater than or equal to | =B2>=50 |
TRUE |
< |
less than | =B2<50 |
FALSE |
<= |
less than or equal to | =B2<=50 |
TRUE |
Two things trip people up here.
First, Excel only understands the two-character versions. If you paste in the single ≥ or ≠ symbol from a document, Excel won't treat it as an operator and the formula breaks. Type >= and <> with your keyboard.
Second, text needs quotation marks and numbers don't. =C2="Durban" checks whether C2 says Durban. =B2>=50 checks a number. Comparisons with text aren't case-sensitive, so "durban" and "Durban" count as a match.
Step 2: The pass or fail formula
Here's a small training assessment. The pass mark is 50%.
| A | B | C | |
|---|---|---|---|
| 1 | Name | Mark (%) | Result |
| 2 | Thandi | 72 | |
| 3 | Pieter | 49 | |
| 4 | Aisha | 50 | |
| 5 | Sipho | 38 |
Click C2 and type:
=IF(B2>=50,"Pass","Fail")
Press Enter. Thandi gets "Pass". Now copy the formula down: select C2 to C5 and press Ctrl+D (Windows) or Cmd+D (Mac), or double-click the small square at the bottom-right corner of C2.
| Name | Mark (%) | Result |
|---|---|---|
| Thandi | 72 | Pass |
| Pieter | 49 | Fail |
| Aisha | 50 | Pass |
| Sipho | 38 | Fail |
Look at Aisha. She scored exactly 50 and she passes, because the test uses >=. If you had typed > instead, she'd fail on the pass mark itself. Always check the person sitting right on the line.
That's the whole Excel pass fail formula. The same pattern works for sales targets (=IF(D2>=25000,"Target met","Below target")) or stock levels (=IF(E2<10,"Reorder","OK")).
Add a second rule with AND or OR
Real rules often have two parts. Say the company also needs at least 80% attendance at the training sessions before anyone passes.
| Name | Mark (%) | Attendance (%) |
|---|---|---|
| Thandi | 72 | 90 |
| Pieter | 49 | 100 |
| Aisha | 50 | 75 |
AND returns TRUE only when every condition is TRUE. Put it inside the IF as the test:
=IF(AND(B2>=50,C2>=80),"Pass","Fail")
Thandi passes. Pieter fails on his mark. Aisha fails on attendance, even though her mark is fine.
OR is more relaxed. It returns TRUE when at least one condition is TRUE. Picture an online shop with this rule: free delivery for orders of R500 or more, or for any order going to Durban.
=IF(OR(B2>=500,C2="Durban"),"Free delivery","R85 delivery")
An order of R620 to Johannesburg gets free delivery. So does an order of R180 to Durban. An order of R300 to Cape Town pays R85.
There's also NOT, which flips TRUE to FALSE and back. =NOT(C2="Durban") is TRUE for every city except Durban. You'll use it less often, but it's handy when it's easier to describe what you don't want.
More than two outcomes: nested IF and IFS
Sometimes two labels aren't enough. Suppose 75% and above is a Distinction, 50% to 74% is a Pass, and below 50% is a Fail.
You can put one IF inside another. This is called a nested IF:
=IF(B2>=75,"Distinction",IF(B2>=50,"Pass","Fail"))
Excel checks the first test. If it's TRUE, it stops and shows "Distinction". If not, it moves on to the second IF. The order matters: start with the highest cut-off and work down. If you test >=50 first, a mark of 90 stops there and never reaches "Distinction".
In Excel 2019 and later, including Microsoft 365, the IFS function does the same job with fewer brackets:
=IFS(B2>=75,"Distinction",B2>=50,"Pass",TRUE,"Fail")
IFS works through each test and pair of answers in turn and returns the first one that's TRUE. The final TRUE,"Fail" is a catch-all for everything else. Leave it out and any mark below 50 gives a #N/A error, because none of the tests matched. If you share files with people on older versions of Excel, stick to nested IF, because IFS won't work for them.
| Mark | Nested IF or IFS result |
|---|---|
| 82 | Distinction |
| 75 | Distinction |
| 74 | Pass |
| 50 | Pass |
| 49 | Fail |
Check it before you trust it
A formula that runs isn't always a formula that's right. Before you send the sheet on, test three marks for every cut-off: one just below, one exactly on it and one just above. For a 50% pass mark, that's 49, 50 and 51. If all three give the answer you expect, your operators are right.
Try it yourself
Reading about IF only gets you so far. It sticks once you've typed it a few times and seen it work.
On ExcelyourTraining you practise in a spreadsheet right in your browser, and each answer is checked the moment you press Enter:
- Start with comparisons and TRUE/FALSE in lesson 11
- Write your first pass or fail formula in lesson 12
- Combine rules with AND, OR and NOT in lesson 13
- Build grade bands with nested IF and IFS in lesson 14
It's free, there's no sign-up and nothing to install. Open lesson 12 and write your first IF in the next five minutes.