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

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.

Excel Functions vs Formulas

Excel functions vs formulas: learn the difference. A formula is the calculation you write; a function is a built-in tool like SUM, AVERAGE or IF that powers it.

Excel Name Error Fix: Why #NAME? Appears and How to Fix It

A practical Excel name error fix: every real cause of #NAME?, from typos and unquoted text to XLOOKUP on an older build, plus the exact fix for each one.

How to Use Excel Formulas: From the First Equals Sign to a Real Report

Learn how to use Excel formulas step by step: the equals sign, cell references, SUM, IF and VLOOKUP, plus the errors beginners hit and how to fix them.

If Statement with Vlookup

Learn how to write an IF statement with VLOOKUP to test lookup results, catch #N/A errors with IFERROR or IFNA, and replace the whole pattern with XLOOKUP.

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.

IFS Function with Multiple Conditions in Excel

The IFS function multiple conditions pattern replaces stacked nested IFs. Learn argument order, AND/OR tests, TRUE fallbacks and how to fix the #N/A error.

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.

What Is a Formula in Excel

What is a formula in Excel? Learn how formulas differ from functions, how cell references and operators work, and build a calculation with SUM, AVERAGE, and IF.

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.