IF Function
IF checks a condition and returns different values based on whether it is true or false.
Syntax
Parameters
| Parameter | Description | Required |
|---|---|---|
| logical_test | The condition to test (must evaluate to TRUE or FALSE). | Required |
| value_if_true | The value to return if the condition is TRUE. | Required |
| value_if_false | Optional. The value to return if the condition is FALSE. | Optional |
Basic Example
Simple conditional check
=IF(A1>100, "Over budget", "Within budget")Returns "Over budget" if A1 > 100, otherwise "Within budget".
Advanced Examples
Example 1: Nested IF statements
Multiple conditionsHandle multiple conditions with nested IFs
=IF(A1>=90, "A", IF(A1>=80, "B", IF(A1>=70, "C", "F")))Example 2: IF with AND/OR
Multiple criteriaCombine multiple conditions
=IF(AND(A1>0, B1>0), "Both positive", "At least one negative")How IF Works
IF evaluates the logical test. If TRUE, it returns value_if_true; if FALSE, it returns value_if_false (or FALSE if omitted).
Important Notes & Limitations
Nested IFs can become hard to read beyond 3-4 levels.
For multiple conditions, consider using IFS function instead.
Common Errors & Fixes
#VALUE!Logical test does not evaluate to TRUE/FALSEFix: Check your condition returns a boolean value.
Download Practice File
IF
ifPractice IF with Real Data
Download a sample CSV file with pre-populated data and practice exercises for the IF function. Works in both Excel and Google Sheets.
File format: CSV (comma-separated values) - opens in Excel, Google Sheets, and all spreadsheet apps