Logic formula
IF in Excel and Google Sheets
Return one value if a condition is true and another if it is false.
Syntax
=IF(logical_test, value_if_true, value_if_false)- logical_test
- A comparison, e.g. B2>100.
- value_if_true
- Result when true.
- value_if_false
- Result when false.
Example
| Row | A | B | C |
|---|---|---|---|
| 1 | Item | Stock | Status |
| 2 | Item A | 40 | |
| 3 | Item B | 8 |
C3 =IF(B3<10,"Reorder","OK")
Result: Reorder
Shows Reorder when stock is below 10.
Ready-to-copy formulas
Overdue flag
=IF(AND(D2<TODAY(),E2<>"Paid"),"Overdue","")Bonus when target is met
=IF(C2>=B2,C2*5%,0)Several levels
=IF(B2>=90,"A",IF(B2>=75,"B","C"))
Tips
- Text results need quotes, numbers do not.
- For many levels, IFS is easier to read.
Need the whole spreadsheet?
Start from a free template with every formula already in place. Opening a template uses no credits.