Logical

IF Formula

IF tests a condition and returns one value when the condition is true and another when it is false. It is the foundation of all decision-making logic in spreadsheets, used for tasks like grading scores, flagging overdue invoices, or categorizing data. You can nest multiple IF functions to handle more than two outcomes.

Syntax

IF(logical_test, value_if_true, value_if_false)
ParameterDescription
logical_test Parameter of the IF function.
value_if_true Parameter of the IF function.
value_if_false Parameter of the IF function.
Try IF in Viztab — free, no signup

Examples

ABC
1StudentScoreResult
2Alice92Pass
3Bob65Fail
4Carol78Pass
5Dave45Fail

Pass or fail based on score

Formula
=IF(B2>=70, "Pass", "Fail")
Returns: "Pass" if the score in B2 is 70 or above, otherwise "Fail"

Apply a discount threshold

Formula
=IF(C2>1000, C2*0.1, 0)
Returns: 10% of the order value if over $1,000, otherwise 0

Nested IF for letter grades

Formula
=IF(B2>=90,"A",IF(B2>=80,"B",IF(B2>=70,"C","F")))
Returns: A, B, C, or F depending on which threshold the score meets

Common Errors

#VALUE!

The condition is comparing incompatible types, like text to a number. Make sure both sides of the comparison are the same type.

Unexpected result

If your IF returns the wrong branch, check whether the cell contains a number stored as text. Use VALUE() to convert it.

Tips

Avoid deep nesting

Instead of nesting more than 3 IF functions, use IFS (if available) or a VLOOKUP/INDEX-MATCH against a reference table.

Empty string for blank

Use "" as the false value to leave a cell visually blank: =IF(A1>0, A1*0.08, "")

Combine with AND/OR

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

Related Formulas