What it does
IF is the basic decision tool in Excel. The first argument is a comparison that results in TRUE or FALSE (B2>=50000, C2="Paid"). If the test is true, the second argument goes into the cell; if not, the third. The result can be a number, text or another formula.
When you need more than two outcomes, IFs are nested: a new IF goes into the value_if_false part. After three or four levels the formula is hard to read; from Microsoft 365 and Excel 2019, IFS does the same in a single level.
To require several conditions at once, build the test with AND; to accept any one of them, use OR. For catching errors, IFERROR is shorter than IF.
Syntax
=IF(logical_test, [value_if_true], [value_if_false])=EĞER(koşul; [doğruysa]; [yanlışsa])Arguments in square brackets are optional. English Excel separates arguments with commas (,) and uses a dot for decimals; Turkish Excel uses semicolons (;) and a decimal comma. Excel shows function names in its own language when it opens the file.
Arguments
| Argument | Required | Description |
|---|---|---|
logical_test | Required | An expression that results in TRUE or FALSE: B2>=50000, C2="Paid", AND(B2>0,C2<>""). A number counts as FALSE when it is 0 and TRUE otherwise. |
value_if_true | Optional | The value returned when the test is true. Text goes in double quotes. If left empty, 0 is returned. |
value_if_false | Optional | The value returned when the test is false. If omitted entirely, FALSE is returned; use "" for an empty result. |
Examples
1Return one of two results based on a target
The formula in C2 is filled down: "Bonus" when sales are 50,000 or more, "No bonus" otherwise.
=IF(B2>=50000,"Bonus","No bonus")| A | B | C | |
|---|---|---|---|
| 1 | Rep | Sales | Status |
| 2 | Emma | 48,500 | No bonus |
| 3 | Liam | 50,000 | Bonus |
| 4 | Olivia | 52,300 | Bonus |
| 5 | Noah | 29,750 | No bonus |
- C2 (filled down to C5)
=IF(B2>=50000,"Bonus","No bonus")
Liam sold exactly 50,000, so the >= test is true and C3 shows Bonus. With > he would miss the bonus.
We recalculated this example in real Excel (Microsoft 365, 16.0) and compared the results: they match.
2Give a letter grade with nested IF
Two nested IFs give three levels. The tests start from the highest threshold, and the first true test decides the result.
=IF(B2>=85,"A",IF(B2>=70,"B","C"))| A | B | C | |
|---|---|---|---|
| 1 | Student | Score | Grade |
| 2 | Mia | 92 | A |
| 3 | Lucas | 85 | A |
| 4 | Ella | 70 | B |
| 5 | Jack | 64 | C |
- C2 (filled down to C5)
=IF(B2>=85,"A",IF(B2>=70,"B","C"))
Lucas's 85 meets the first test and gets A; Ella's 70 is caught by the second: B. Jack meets neither, so he gets C.
We recalculated this example in real Excel (Microsoft 365, 16.0) and compared the results: they match.
3Test two conditions together with AND
A discount applies only when the amount is over 1,000 and the customer is a "Dealer"; other rows get 0. The test is built with AND.
=IF(AND(A2="Dealer",B2>1000),B2*0.05,0)| A | B | C | D | |
|---|---|---|---|---|
| 1 | Customer Type | Amount | Discount | |
| 2 | Dealer | 2,400.00 | 120.00 | |
| 3 | Retail | 3,150.00 | 0.00 | |
| 4 | Dealer | 860.00 | 0.00 | |
| 5 | Dealer | 1,000.50 | 50.03 |
- D2 (filled down to D5)
=IF(AND(A2="Dealer",B2>1000),B2*0.05,0)
Only the first and fourth rows meet both conditions: D2 shows 120.00 and D5 shows 50.03. The retail row has a high amount but gets no discount.
We recalculated this example in real Excel (Microsoft 365, 16.0) and compared the results: they match.
Common errors and fixes
- #NAME?
Cause: A text result was typed without quotes (
=IF(B2>10,High,Low)), so Excel takes High for a name.Fix: Wrap text in double quotes:
"High".- Always the same result
Cause: A number is stored as text, so comparing
"50000"with 50000 does not work as expected; or the test puts the number in quotes (B2>"100").Fix: Write numbers without quotes and make sure the cells really contain numbers.
- #VALUE!
Cause: A cell used in the test contains an error or text that cannot be read as a number.
Fix: Fix that cell first, or guard the formula with IFERROR.
Good to know
- Not equal to is written
<>:C2<>"Cancelled". - To test for an empty cell use
B2=""or ISBLANK. - In nested IFs, write the conditions starting from the highest threshold; the formula stops at the first true test.
In Nexell
Get Nexell to do it from a sentence
Add a Status column that says "Bonus" when sales are 50,000 or more and "No bonus" otherwise
Convert to tableBring your table into the tool and type this. Nexell adds the Status column with an IF formula and shows in the preview which row gets which value. In the downloaded file, the status changes when the amount changes.
Nexell uses AI to understand the request and builds the result with real Excel formulas; the formula may differ from the example on this page. You see a preview first and nothing changes until you press Apply; formulas stay live in the downloaded .xlsx file.
Free account · no card needed · 30 credits a month
Frequently asked questions
How many conditions can an IF formula have?
A single IF takes one test, and up to 64 IFs can be nested. Use AND when all conditions must hold and OR when any one is enough; for multi-level grading, IFS is easier to read.
How do I leave a cell blank with IF?
Return empty text: =IF(B2="","",B2*1.2). The cell looks empty but still holds the formula.