New

Admissions Open for ADCA & MDCAA 2026 Batch!

Apply Now
{}[]<>()/;=

IF Function in Excel

Article · 7 min read Free Preview
The IF function in Excel checks a condition and returns one value if it's true and another if it's false. The formula is `=IF(condition, value_if_true, value_if_false)`. This guide covers simple IF, nested IF, and IF combined with AND and OR, with worked examples.

The IF function in Excel checks whether a condition is true or false, then returns one value if it's true and a different value if it's false. The formula is =IF(condition, value_if_true, value_if_false). For example, =IF(A2>=33,"Pass","Fail") shows "Pass" when a mark is 33 or above, and "Fail" otherwise. It's the function you reach for whenever a result depends on a rule.

What the IF function does

IF makes a decision for you. You give it a question that can only be yes or no, and two answers. If the question is true, Excel shows the first answer. If it's false, it shows the second.

Common uses in real work:

  • Marking students Pass or Fail
  • Flagging invoices as Paid or Pending
  • Giving a bonus only when a target is met

The three parts of IF

=IF(logical_test, value_if_true, value_if_false)
  1. logical_test — the condition to check, like A2>=33 or B2="Delhi".
  2. value_if_true — what to show if the condition is true. Text goes in quotes: "Pass".
  3. value_if_false — what to show if the condition is false.

Step by step: a Pass/Fail formula

Say marks are in column A and the pass mark is 33.

  1. Click cell B2.
  2. Type =IF(
  3. Click A2, then type >=33.
  4. Type ,"Pass","Fail") and press Enter.

Your formula: =IF(A2>=33,"Pass","Fail")

Copy it down the column to grade the whole class.

Worked example (student marksheet)

StudentMarksResult =IF(B2>=33,"Pass","Fail")
Priya45Pass
Karan28Fail
Sana33Pass

Sana scores exactly 33 and still passes, because >= means "greater than or equal to".

Nested IF (more than two outcomes)

When you need grades instead of just Pass/Fail, put one IF inside another. This is called a nested IF.

=IF(B2>=75,"A",IF(B2>=60,"B",IF(B2>=33,"C","Fail")))

Excel checks each condition in order and stops at the first true one. A student with 62 gets "B".

If you have Microsoft 365, the IFS function does the same job more cleanly:

=IFS(B2>=75,"A",B2>=60,"B",B2>=33,"C",TRUE,"Fail")

IF with AND / OR

Use AND when every condition must be true. Use OR when any one is enough.

=IF(AND(B2>=33,C2>=33),"Pass","Fail")

This passes a student only if they clear 33 in both subjects.

=IF(OR(City="Delhi",City="Mumbai"),"Metro","Other")

Pro tips

  • Put text answers in double quotes ("Pass"), but never put numbers in quotes if you want to calculate with them later.
  • Keep nested IFs to three or four levels. Beyond that, switch to IFS or VLOOKUP with a lookup table.
  • To leave a cell blank when false, use empty quotes: =IF(A2>=33,"Pass","").

Common mistakes

  • Missing a closing bracket. Each IF needs its own ). A nested IF with three IFs needs three closing brackets.
  • Forgetting quotes on text. =IF(A2>=33,Pass,Fail) gives an error. Text must be "Pass".
  • Wrong operator. = means equal, >= means greater-or-equal. Mixing these changes who passes.
  • Comparing text with numbers. "33" (text) and 33 (number) are not the same to Excel.

Key takeaways

  • IF returns one value when a condition is true and another when it's false.
  • The formula is =IF(condition, value_if_true, value_if_false).
  • Nest IFs (or use IFS) for more than two outcomes.
  • Combine IF with AND/OR to check several conditions at once.

Practice task

Make a list of five order amounts. Write an IF formula that shows "Free Delivery" when the amount is 500 or more, and "Add ₹50" when it's less. Then extend it with a nested IF to add a "Premium" tag for amounts over 2,000.

The IF function is the start of Excel logic. To build full reports and dashboards for a job, see the ADCA (AI Integrated) program at HCI.

Frequently Asked Questions

What is the IF function in Excel?

The IF function checks a condition and returns one value if it's true and another if it's false. The formula is `=IF(condition, value_if_true, value_if_false)`.

How do I write an IF formula for Pass or Fail?

Use `=IF(A2>=33,"Pass","Fail")`, where A2 holds the marks and 33 is the pass mark. Copy it down to grade a whole list.

What is a nested IF?

A nested IF is an IF placed inside another IF to handle more than two outcomes, such as grades A, B, C and Fail. Excel checks the conditions in order and returns the first true one.

How do I use IF with two conditions?

Combine IF with AND or OR. Use `=IF(AND(cond1,cond2),"Yes","No")` when both must be true, or OR when any one is enough.

Can the IF function return a blank cell?

Yes. Use empty double quotes for the result you want blank, for example `=IF(A2>=33,"Pass","")`.

Need help? Chat with us!