Syntax
| Parameter | Description |
|---|---|
| logical_test | Parameter of the IF function. |
| value_if_true | Parameter of the IF function. |
| value_if_false | Parameter of the IF function. |
Examples
| A | B | C | |
|---|---|---|---|
| 1 | Student | Score | Result |
| 2 | Alice | 92 | Pass |
| 3 | Bob | 65 | Fail |
| 4 | Carol | 78 | Pass |
| 5 | Dave | 45 | Fail |
Pass or fail based on score
=IF(B2>=70, "Pass", "Fail")
Apply a discount threshold
=IF(C2>1000, C2*0.1, 0)
Nested IF for letter grades
=IF(B2>=90,"A",IF(B2>=80,"B",IF(B2>=70,"C","F")))
Common Errors
The condition is comparing incompatible types, like text to a number. Make sure both sides of the comparison are the same type.
If your IF returns the wrong branch, check whether the cell contains a number stored as text. Use VALUE() to convert it.
Tips
Instead of nesting more than 3 IF functions, use IFS (if available) or a VLOOKUP/INDEX-MATCH against a reference table.
Use "" as the false value to leave a cell visually blank: =IF(A1>0, A1*0.08, "")
Test multiple conditions: =IF(AND(B2>=70, C2>=70), "Pass", "Fail") requires both scores to be 70+.
Try IF in Viztab
Import your data and use IF with 370+ other formulas. No signup required.
Open Viztab