How to Use IF in Excel
The foundation of every decision formula in Excel: returns one value when a condition is TRUE and another when it is FALSE.
What is IF in Microsoft Excel?
IF evaluates a condition and returns a value you choose for each outcome. It is the most used function in Excel because almost every real report needs a decision — pass or fail, target met or missed, discount or no discount. You can nest IF inside IF, but modern Excel prefers IFS for readability.
Formula Syntax
Arguments Breakdown
| Argument | Requirement | Purpose & Details |
|---|---|---|
| logical_test | Required | Any expression that evaluates to TRUE or FALSE, such as B2>=40 or A2="North". |
| value_if_true | Required | What to return when the test is TRUE. Can be text, a number, a cell reference or another formula. |
| value_if_false | Optional | What to return when the test is FALSE. If omitted, Excel returns FALSE. |
When to Use IF (Real-World Business Scenarios)
- 1
Flagging rows that need attention, such as orders over 30 days old or invoices above a credit limit.
- 2
Converting raw numbers into business labels like Pass/Fail, High/Medium/Low, or On Track/At Risk.
- 3
Calculating conditional values such as a 10% discount only when the order value crosses a threshold.
Step-by-Step Practical Business Example
Suppose you have the following dataset in Excel cells A1:D4:
| Student | Marks | Result |
|---|---|---|
| Rahul | 78 | Pass |
| Pooja | 34 | Fail |
| Aman | 56 | Pass |
How it works: Checks whether Marks in B2 is 40 or more. Since 78 passes the test, the formula returns 'Pass'. Dragging it down evaluates every row independently.
Common Errors & How to Fix Them
Why it happens: Text was used in a numeric comparison, for example comparing a number to "40" written with invisible spaces.
Fix: Compare like with like: =IF(B2>=40,...) for numbers and =IF(A2="North",...) for text. Wrap text comparisons in quotes.
Why it happens: The logical test was written as text instead of an expression, such as =IF("B2>=40","Pass","Fail").
Fix: Remove the quotes around the test so Excel evaluates the cell value rather than the literal string.
Try IF Live in Your Browser
No need to launch desktop Excel. Practice formulas with real-time feedback in our HyperFormula sandbox.
Frequently Asked Questions (IF)
What does the IF formula do in Excel?
IF evaluates a condition and returns a value you choose for each outcome. It is the most used function in Excel because almost every real report needs a decision — pass or fail, target met or missed, discount or no discount. You can nest IF inside IF, but modern Excel prefers IFS for readability.
What is the syntax for IF?
What are common mistakes when using IF?
#VALUE!: Text was used in a numeric comparison, for example comparing a number to "40" written with invisible spaces. (Compare like with like: =IF(B2>=40,...) for numbers and =IF(A2="North",...) for text. Wrap text comparisons in quotes.) Wrong result / always FALSE: The logical test was written as text instead of an expression, such as =IF("B2>=40","Pass","Fail"). (Remove the quotes around the test so Excel evaluates the cell value rather than the literal string.)
Related Excel Formulas
Keep building your formula toolkit with these logical functions.
- IFSEvaluates multiple logical conditions sequentially without complex nested IF statements.
- IFERRORCatches and replaces formula errors (#N/A, #VALUE!, #DIV/0!) with clean fallbacks or blanks.
- IFNACatches only #N/A errors, leaving every other error visible so real bugs are never hidden.
- SWITCHReplaces long chains of nested IF with one readable list of value-and-result pairs.
- XLOOKUPThe modern, versatile replacement for VLOOKUP and HLOOKUP that searches in any direction without column index numbers.
- VLOOKUPThe industry-standard vertical lookup function that searches the first column of a table and returns a value in the same row.
Master IF in Basic Excel
Learn IF along with our formula library, practice files, and verifiable certificates in our complete curriculum.
