The IF function is one of the most versatile functions in Excel, LibreOffice Calc, and Google Sheets. It allows you to perform logical tests and return different values based on whether a condition is TRUE or FALSE.
IF Formula Syntax
=IF(logical_test, value_if_true, value_if_false)
10 Practical IF Formula Examples
1. Basic IF Statement
Check if a value is greater than 100:
=IF(A1>100, "High", "Low")
2. IF with Text Comparison
Check if a cell contains specific text:
=IF(A1="Yes", "Approved", "Pending")
3. IF with AND Function
Check multiple conditions (both must be true):
=IF(AND(A1>50, B1>50), "Pass", "Fail")
4. IF with OR Function
Check multiple conditions (either can be true):
=IF(OR(A1>100, B1>100), "Bonus", "Regular")
5. Nested IF Statements
Multiple conditions with nested IFs:
=IF(A1>=90, "A", IF(A1>=80, "B", IF(A1>=70, "C", "F")))
6. IF with Calculations
Perform calculations based on conditions:
=IF(A1>100, A1*1.1, A1*1.05)
7. IF with ISBLANK
Check if a cell is empty:
=IF(ISBLANK(A1), "No Data", A1)
8. IF with SUM
Conditional summing:
=IF(SUM(A1:A10)>1000, "Target Met", "Target Not Met")
9. IF for Date Comparisons
Check if a date is in the past:
=IF(A1
10. IF with VLOOKUP
Combine IF with VLOOKUP for error handling:
=IF(ISNA(VLOOKUP(A1, B:C, 2, FALSE)), "Not Found", VLOOKUP(A1, B:C, 2, FALSE))
Tips for Using IF Formulas
- Always use quotes for text values:
"Yes", notYes - Use parentheses to group conditions in complex formulas
- Consider using IFS function (Excel 2016+) for multiple conditions instead of nested IFs
- Test your formulas with different values to ensure they work correctly
Generate IF Formulas Instantly
Need help creating complex IF formulas? Use ExcelFormula Pro to generate them with AI. Just describe what you need!
Try FreeConclusion
The IF function is essential for conditional logic in spreadsheets. Whether you're grading exams, calculating bonuses, or filtering data, IF formulas make your spreadsheets dynamic and intelligent.