Concept
1. What does IF do?
IF asks a question: "Is this condition true or not?" If true, it returns one answer; if false, another.
=IF(logical_test, value_if_true, value_if_false)
Simple example: =IF(B2>=40, "Pass", "Fail") — if B2 is 40 or more, "Pass"; otherwise "Fail".
2. Comparison operators
| Operator | Meaning | Example |
|---|---|---|
= |
equal to | B2=100 |
<> |
not equal to | B2<>0 |
> |
greater than | B2>50 |
< |
less than | B2<50 |
>= |
greater than or equal to | B2>=40 |
<= |
less than or equal to | B2<=40 |
3. Practice sheet
| A | B | C | D | |
|---|---|---|---|---|
| 1 | Salesperson | Target | Sales | Status |
| 2 | Amit | 50000 | 62000 | |
| 3 | Neha | 50000 | 48000 | |
| 4 | Ravi | 40000 | 40000 |
In D2 type =IF(C2>=B2, "Achieved", "Missed") and drag down. Result: Achieved, Missed, Achieved.
Ravi's sales are exactly 40000, which is why we used >=. With just >, he would get "Missed". Always think about the boundary case when choosing an operator.
4. Calculations inside IF
IF can return numbers, not just text. Incentive in column E: 5% of sales if the target is achieved, otherwise 0.
=IF(C2>=B2, C2*5%, 0)
Amit gets 3100, Neha 0, Ravi 2000.
5. Comparing text
Always put text in double quotes: =IF(A2="Amit", "Manager", "Staff"). Text comparison in IF is case-insensitive — "amit" and "AMIT" are treated the same.
6. Checking for blank cells
If sales haven't been entered yet, show nothing:
=IF(C2="", "", IF(C2>=B2, "Achieved", "Missed"))
"" means empty. (This is a small nested IF; the full concept is in the next lesson.)
Common mistakes
Forgetting quotes around text (=IF(B2>40, Pass, Fail) gives a #NAME? error). Putting numbers in quotes ("40" becomes text and the comparison can go wrong). And choosing the wrong operator (> vs >=) for the boundary case.