IF
Returns one value when a condition is true and another when it's false
Spreadsheet editor
Spreadsheet editor
Syntax
=IF(Logical_test, Value_if_true, Value_if_false)
Returns: Varies Arguments
| Argument | Required | Description |
|---|---|---|
| Logical_test | Yes | The condition that you want to test. It can be an expression, a value, or a cell reference. |
| Value_if_true | Yes | The value or formula to return if the logical test evaluates to TRUE. |
| Value_if_false | No | The value or formula to return if the logical test evaluates to FALSE. |
About
This function works for countless scenarios: marking students as pass or fail, applying discounts to sales over a threshold, or displaying custom messages based on inventory levels. Combine IF with functions like AND and OR to test multiple conditions at once, or use IFS when you need to check several conditions in sequence.
IF is available in all Excel versions and forms the foundation for more advanced logical operations.
Exercises using IF
IF with numeric output
BeginnerCalculate a 10% bonus if sales exceed target, otherwise 0.
Open exerciseSimple IF statement
BeginnerCategorize sales as "On target" or "Below target" based on a threshold.
Open exerciseCreating an IFNOTERROR function
BeginnerOpen exercise
Flag overdue invoices with IF and NOT
BeginnerUse IF combined with NOT to flag overdue invoices that are not marked as paid.
Open exercisePracticing and, or, and if
BeginnerOpen exercise
Aging buckets
IntermediateCategorize receivables into aging buckets (Current, Slightly overdue, Moderately overdue, Seriously overdue).
Open exerciseNested IF for grading
IntermediateAssign letter grades (A, B, C, D, F) based on numerical scores.
Open exerciseIF with OR
IntermediateFlag high-priority orders (either > $10,000 OR customer is "VIP").
Open exerciseIF with AND
IntermediateApprove a loan only if credit score > 700 AND income > $50,000.
Open exerciseNested IF with AND/OR for eligibility
IntermediateDetermine training eligibility using IF with nested AND and OR tests.
Open exerciseNested IF for commission tiers
IntermediateCalculate sales commission using a 3-tier rate structure.
Open exerciseRemove duplicate customer records
IntermediateUse COUNTIF with an expanding range to mark which customer records to keep and which repeats to remove.
Open exerciseBuild a one-variable sensitivity table
IntermediateBuild a project NPV model and test whether it clears a required threshold under different discount rates.
Open exerciseA/B test results analysis
AdvancedCompare two experiment variants by calculating conversion rates, percentage lift, standard errors, and a significance decision.
Open exerciseBank statement reconciliation
AdvancedReconcile a bank statement with internal records, identify missing items.
Open exerciseComplex commission structure
AdvancedCalculate commissions with tiered rates, team bonuses, and caps.
Open exerciseFull data reconciliation
AdvancedMatch transactions between two systems, flag discrepancies by type.
Open exercisePareto analysis (80/20)
AdvancedBuild a complete Pareto analysis ranking defect categories by frequency with cumulative percentages and 80/20 classification.
Open exerciseExamples
Empty cell handling
Spreadsheet editor
Missing third argument mistake
Spreadsheet editor
Nested IF with AND function
Spreadsheet editor
Watch out for
Missing value_if_false causes confusion
Leaving out the third argument returns FALSE instead of a blank when the condition isn't met, which can mess up calculations or formatting.
→ Always include the third argument. Use empty quotes ("") if you want a blank result when the condition is false.
Text comparisons are case-insensitive
IF treats "apple" and "APPLE" as the same value, which might not match your intent when comparing text.
→ Use EXACT within your IF statement when you need case-sensitive text comparisons.