Making Decisions with IF
The IF function checks a condition and shows one answer if it is true and another if it is false.
What you will learn
- Write an IF with its three parts
- Use comparison signs like greater-than
- Label data automatically based on a rule
- Chain IFs together for more than two answers
IF lets Excel decide
So far formulas just calculated. The IF function lets Excel make a decision. It asks a yes/no question, then shows one thing if the answer is yes (true) and a different thing if the answer is no (false).
IF takes three parts inside its brackets, separated by commas:
- The test — a question that is either true or false, like is B2 more than 50?
- The value if true — what to show when the test passes.
- The value if false — what to show when the test fails.
The comparison signs
| Sign | Means | Example test |
|---|---|---|
= | equal to | B2=100 |
> | greater than | B2>50 |
< | less than | B2<50 |
>= | greater than or equal to | B2>=50 |
<= | less than or equal to | B2<=50 |
<> | not equal to | B2<>0 |
A worked example: pass or fail
Imagine a test score in B2. We want column C to say Pass if the score is 50 or more, and Fail if it is below 50:
=IF(B2>=50, "Pass", "Fail")Note: Output:
If B2 is 72, the cell shows Pass.
If B2 is 41, the cell shows Fail.
Excel checked the test B2>=50. When it was true it picked the second part (Pass); when it was false it picked the third part (Fail). Copy it down and every student is graded instantly.
Watch out: Wrap any text answer in double quotes, like "Pass". Numbers do not need quotes. Forgetting the quotes around text is a common cause of errors.
More than two answers: IF inside IF
A plain IF gives only two answers. But what if you need three or more, like grades A, B or C? You put another IF in the false slot — this is called nesting. Read it as a chain of questions: is it an A? If not, is it a B? If not, it must be a C.
Say a score sits in B2: 80 or more is an A, 50 to 79 is a B, and anything below 50 is a C.
=IF(B2>=80, "A", IF(B2>=50, "B", "C"))Note: Output:
If B2 is 85, the cell shows A.
If B2 is 64, the cell shows B.
If B2 is 30, the cell shows C.
Excel checked B2>=80 first. When that was false (for 64), it moved on to the second IF and checked B2>=50, which was true, so it showed B. The order matters: always test the highest band first.
Tip: You can put a calculation inside an IF, not just text. For example =IF(B2>100, B2*0.9, B2) gives a 10% discount only when the amount is over 100, and leaves it unchanged otherwise.
Watch out: In a nested IF, count your closing brackets at the end — you need one ) for every IF you opened. Newer Excel also offers IFS, which avoids the pile of brackets, but plain nested IF works everywhere.
Q. What does =IF(A1>10, "Big", "Small") show when A1 contains 4?
A1>10 is false because 4 is not greater than 10, so IF shows the false answer, Small.✍️ Practice
- Put the numbers 30, 55, 80 in column B and write an IF in column C that shows Pass for 50 or more.
- Use a nested IF to grade the same scores as A (80+), B (50–79) or C (below 50).
🏠 Homework
- Make a list of six exam scores and use IF to label each as Pass or Fail. Then upgrade your formula to a nested IF that gives A, B or C grades instead.