Skip to content

Excel function · Logical

Excel IF function

IF tests a condition and returns one value when it is true and another when it is false: "Bonus" when sales hit the target, "No bonus" otherwise.

In Turkish Excel: EĞER

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

English Excel=IF(logical_test, [value_if_true], [value_if_false])
Turkish Excel=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

ArgumentRequiredDescription
logical_testRequiredAn 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_trueOptionalThe value returned when the test is true. Text goes in double quotes. If left empty, 0 is returned.
value_if_falseOptionalThe 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.

C2fx=IF(B2>=50000,"Bonus","No bonus")
Return one of two results based on a target: example table
ABC
1RepSalesStatus
2Emma48,500No bonus
3Liam50,000Bonus
4Olivia52,300Bonus
5Noah29,750No 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.

C2fx=IF(B2>=85,"A",IF(B2>=70,"B","C"))
Give a letter grade with nested IF: example table
ABC
1StudentScoreGrade
2Mia92A
3Lucas85A
4Ella70B
5Jack64C
  • 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.

D2fx=IF(AND(A2="Dealer",B2>1000),B2*0.05,0)
Test two conditions together with AND: example table
ABCD
1Customer TypeAmountDiscount
2Dealer2,400.00120.00
3Retail3,150.000.00
4Dealer860.000.00
5Dealer1,000.5050.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

Type this in Nexell

Add a Status column that says "Bonus" when sales are 50,000 or more and "No bonus" otherwise

Convert to table

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

Related functions

All logical functions →

Stop memorising formulas. Describe them.

Bring your table into the tool and say what you need; Nexell builds the formula and shows it in a preview.

Try it free