IF
How to use the IF function in Excel (with examples)
IF tests a condition: it returns one result if the condition is true and another if it is false.
Syntax
=IF(logical_test, value_if_true, value_if_false)
- logical_test — An expression that returns TRUE or FALSE, e.g. B2>=60.
- value_if_true — The value or formula returned when the condition is met.
- value_if_false — The value returned when the condition is not met.
Example
Formula:
=IF(B2>=60,"Passed","Retake")→ result: Passed
Comparison operators
= equal to, <> not equal to, > greater than, < less than, >= greater than or equal to, <= less than or equal to. Text goes in double quotes.
Nested IF
For several outcomes, nest IFs inside each other: =IF(B2>=86,5,IF(B2>=70,4,IF(B2>=55,3,2))). In Excel 2019+ the IFS function makes this simpler.
Calculations inside IF
IF can return a formula as its result: =IF(B2>10000000,B2*5%,0) gives a 5% bonus when sales exceed 10 million.
Put it into practice
Frequently asked questions
=IF(A2="Tashkent","Capital","Region"). The comparison is not case-sensitive.
=IF(A2="","Empty","Filled") or =IF(ISBLANK(A2),...).
You can nest up to 64 IFs, but with more than 3 conditions it's better to use IFS or VLOOKUP.