Quick Answer

IF Function

IF checks a condition and returns different values based on whether it is true or false.

✓ Excel✓ Google SheetsExcel All versions

Syntax

IF
(logical_test, value_if_true, [value_if_false])

Parameters

ParameterDescriptionRequired
logical_testThe condition to test (must evaluate to TRUE or FALSE).Required
value_if_trueThe value to return if the condition is TRUE.Required
value_if_falseOptional. The value to return if the condition is FALSE.Optional

Basic Example

Simple conditional check

=IF(A1>100, "Over budget", "Within budget")
ResultOver budget

Returns "Over budget" if A1 > 100, otherwise "Within budget".

Advanced Examples

Example 1: Nested IF statements

Multiple conditions

Handle multiple conditions with nested IFs

=IF(A1>=90, "A", IF(A1>=80, "B", IF(A1>=70, "C", "F")))
Result: B
Assigns letter grades based on score ranges.

Example 2: IF with AND/OR

Multiple criteria

Combine multiple conditions

=IF(AND(A1>0, B1>0), "Both positive", "At least one negative")
Result: Both positive
Checks if both values are positive using AND.

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).

1
Define condition
Determine the logical test you want to perform.
2
Set true result
Decide what to return if the condition is TRUE.
3
Set false result
Decide what to return if the condition is FALSE.
4
Enter formula
Type =IF(condition, true_value, false_value).

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/FALSE

Fix: Check your condition returns a boolean value.

Download Practice File

Practice 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.

Works in Google SheetsCompatible with ExcelIncludes exercises

File format: CSV (comma-separated values) - opens in Excel, Google Sheets, and all spreadsheet apps

Related Tutorials

Frequently Asked Questions

Can IF return formulas?
Yes, IF can return any value including formulas.
What happens if value_if_false is omitted?
IF returns FALSE when the condition is FALSE and value_if_false is omitted.