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
Related Tutorials
Excel Budget Template
Build an Excel budget template from scratch: structure your sheets, total spending by category with SUMIF, flag overspending with IF, and track averages.
IF with AND / OR
Combining IF with AND OR logic lets a single formula test several conditions at once. Learn the syntax, nesting order and Excel and Google Sheets examples.
Nested If Alternatives
Long nested IF formulas are hard to read and easy to break. Discover the best nested IF alternatives in Excel and Google Sheets — IFS, lookup tables, and XLOOKUP.