Excel tutorial
/

Functions

Beginner

Excel IF function: results by condition, nested IF and IF with AND

Testing conditions with IF in Excel: pass/fail, bonuses, stock levels; nested IF for a grading scale, IF+AND, and the quotes and blank-cell traps — with examples.

IF is the function that teaches Excel to “make decisions”. It tests a condition: if the condition is met it returns one value, otherwise another.

You see it everywhere: a score of 60 or more is “Pass”, otherwise “Fail”; sales above target earn a bonus; stock running low means “Reorder”. You write one formula, fill it down thousands of rows, and Excel decides for every row on its own.

Книга1 - Excel
—☐✕
C2fx=ЕСЛИ(B2>=60;"Pass";"Fail")
ABCD
1StudentScoreResult
2Aziz92Pass
3Dilnoza78Pass
4Javohir55Fail
5Malika43Fail
6Sardor67Pass
7
Готово
=ЕСЛИ(B2>=60;"Pass";"Fail") in C2: a score of 60 or more gives “Pass”, anything else “Fail”

Syntax

=ЕСЛИ(logical_test; [value_if_true]; [value_if_false])

  • logical_test — a condition that returns TRUE or FALSE: B2>=60, C2="Tashkent", D2<>0.
  • value_if_true — what to return when the condition is met: text, a number, a cell or another formula.
  • value_if_false — what to return when it is not met. If you leave it out, Excel returns FALSE.

Comparison operators: = equal, <> not equal, > greater, < less, >= greater or equal, <= less or equal.

Golden rule: text in a formula always goes in quotes — "Pass". Numbers and cell addresses go without quotes — 60, B2.

Example

AB
1Sales12500000
2Target10000000

Formula:

=IF(B1>=B2,"Target met","Not met")

→ result: Target met

Entering IF step by step

1

Select the result cell (C2) and choose Формулы → Логические → IF.

Книга1 - Excel
—☐✕
ФайлГлавнаяВставкаРазметка страницыФормулыДанныеРецензированиеВидСправка
Вставить функциюАвтосуммаФинансовыеЛогическиеТекстовыеДата и времяСсылки и массивыМатематические
Библиотека функций
Диспетчер имён
Определённые имена
C2fx
ABCD
1StudentScoreResult
2Aziz92
3Dilnoza78
4Javohir55
5
Готово

2

In the Function Arguments window fill in three boxes: Logical_test — B2>=60, Value_if_true — Pass, Value_if_false — Fail. In this window Excel adds the quotes for you; when typing in a cell you add them yourself.

Книга1 - Excel
—☐✕
C2fx=ЕСЛИ(B2>=60;"Pass";"Fail")
ABCD
1StudentScoreResult
2Aziz92Pass
3Dilnoza78
4Javohir55
5
Готово

3

Click OK, then double-click the fill handle of C2 to copy the formula down. Each row is tested against its own score.

Книга1 - Excel
—☐✕
C2fx=ЕСЛИ(B2>=60;"Pass";"Fail")
ABCD
1StudentScoreResult
2Aziz92Pass
3Dilnoza78Pass
4Javohir55Fail3
5
ГотовоКоличество: 3
Книга1 - Excel
—☐✕
C3fx=ЕСЛИ(B3<$E$2;"Reorder";"Enough")
ABCDEF
1ProductIn stockStatusMinimum
2Rice120Enough501
3Oil35Reorder
4Sugar50Enough
5Flour18Reorder
6
Готово
The threshold lives in its own cell (E2), locked with $E$2: change the minimum and every status recalculates. Sugar at 50 is “Enough”, because 50<50 is false

Nested IF: more than two outcomes

IF only splits into two paths. For three or more outcomes, put another IF in place of value_if_false. For example, a grade on a 100-point scale:

=ЕСЛИ(B2>=86;"Excellent";ЕСЛИ(B2>=71;"Good";ЕСЛИ(B2>=55;"Fair";"Poor")))

Excel checks the conditions left to right and stops at the first one that is true. That is why the order “largest to smallest” matters: first >=86, then >=71, then >=55. You need as many closing brackets as IFs — three ) at the end here.

Книга1 - Excel
—☐✕
C3fx=ЕСЛИ(B3>=86;"Excellent";ЕСЛИ(B3>=71;"Good";ЕСЛИ(B3>=55;"Fair";"Poor")))
ABCD
1StudentScoreGrade
2Aziz92Excellent
3Dilnoza78Good
4Javohir55Fair
5Malika43Poor
6Sardor86Excellent
7
Готово
Dilnoza, 78: the first test (>=86) is FALSE, the second (>=71) is TRUE, so Excel returns “Good” and skips the rest
Книга1 - Excel
—☐✕
D3fx=ЕСЛИ(ЕПУСТО(B3);"Absent";ЕСЛИ(B3>=60;"Pass";"Fail"))
ABCDE
1StudentScorePlain IFCorrect
2Aziz92PassPass
3JavohirFail1Absent
4Malika43FailFail
5
Готово
Javohir missed the exam, yet the plain IF gave him “Fail”. Check for blanks first: ISBLANK(B3) or B3=""

Pro level: IF + AND/OR, IFS and calculations

  • Several conditions together: =ЕСЛИ(И(B2>=10000000;C2=0);B2*10%;0) — a bonus if sales exceed 10 million and there were no late arrivals. For “or” use OR: =ЕСЛИ(ИЛИ(D2="VIP";B2>=5000000);"Discount";"").
  • IF can calculate: return a formula instead of text — B2*10%, SUM(C2:E2), B2-C2.
  • Leave it blank: use "" as value_if_false and the cell looks empty.
  • IFS (Excel 2019/365): a flat list instead of nesting — =ЕСЛИМН(B2>=86;"Excellent";B2>=71;"Good";B2>=55;"Fair";ИСТИНА;"Poor"). The final TRUE means “everything else”.
  • Multi-tier scales (tax, commission, discounts): don’t write more than 4–5 IFs — put the thresholds in a separate table and use XLOOKUP or an approximate-match VLOOKUP.
Книга1 - Excel
—☐✕
D2fx=ЕСЛИ(И(B2>=10000000;C2=0);B2*10%;0)
ABCDE
1EmployeeSalesLate daysBonus
2Aziz12 500 00001 250 000
3Dilnoza11 000 00020
4Javohir15 000 00001 500 000
5Malika8 000 00000
6
Готово
IF + AND: Dilnoza hit her sales target but was late twice — bonus 0. The result is a calculated number, not text: B2*10%

Try it in the simulator

Type =ЕСЛИ(B2>=60;"Pass";"Fail") in C2 and fill it down to C6. Then write a nested IF in D2: =ЕСЛИ(B2>=86;"Excellent";ЕСЛИ(B2>=71;"Good";ЕСЛИ(B2>=55;"Fair";"Poor"))) and fill it down too. Malika should get “Fail” and “Poor”.

Книга1 - Excel
—☐✕
Буфер обмена
Шрифт
Выравнивание
Число
Стили
Ячейки
Редактирование
✕✓fx
ABCDEFGHIJKLMNOPQRSTUVWX
1StudentScoreResultGrade
2Aziz92
3Dilnoza78
4Javohir55
5Malika43
6Sardor67
7
8
9
10
Лист1
Готово

Has ExcelLab been useful?

Support the project and help us release new lessons and exercises.

Support us
Previous

79 / 154