Excel BasicsCore· 35 min read

Making Decisions with IF

The IF function checks a condition and shows one answer if it is true and another if it is false.

What you will learn

  • Write an IF with its three parts
  • Use comparison signs like greater-than
  • Label data automatically based on a rule
  • Chain IFs together for more than two answers

IF lets Excel decide

So far formulas just calculated. The IF function lets Excel make a decision. It asks a yes/no question, then shows one thing if the answer is yes (true) and a different thing if the answer is no (false).

IF takes three parts inside its brackets, separated by commas:

  1. The test — a question that is either true or false, like is B2 more than 50?
  2. The value if true — what to show when the test passes.
  3. The value if false — what to show when the test fails.

The comparison signs

SignMeansExample test
=equal toB2=100
>greater thanB2>50
<less thanB2<50
>=greater than or equal toB2>=50
<=less than or equal toB2<=50
<>not equal toB2<>0

A worked example: pass or fail

Imagine a test score in B2. We want column C to say Pass if the score is 50 or more, and Fail if it is below 50:

Show Pass when the score reaches 50, otherwise Fail
=IF(B2>=50, "Pass", "Fail")

Note: Output: If B2 is 72, the cell shows Pass. If B2 is 41, the cell shows Fail. Excel checked the test B2>=50. When it was true it picked the second part (Pass); when it was false it picked the third part (Fail). Copy it down and every student is graded instantly.

Watch out: Wrap any text answer in double quotes, like "Pass". Numbers do not need quotes. Forgetting the quotes around text is a common cause of errors.

More than two answers: IF inside IF

A plain IF gives only two answers. But what if you need three or more, like grades A, B or C? You put another IF in the false slot — this is called nesting. Read it as a chain of questions: is it an A? If not, is it a B? If not, it must be a C.

Say a score sits in B2: 80 or more is an A, 50 to 79 is a B, and anything below 50 is a C.

Grade A, B or C by chaining a second IF in the false slot
=IF(B2>=80, "A", IF(B2>=50, "B", "C"))

Note: Output: If B2 is 85, the cell shows A. If B2 is 64, the cell shows B. If B2 is 30, the cell shows C. Excel checked B2>=80 first. When that was false (for 64), it moved on to the second IF and checked B2>=50, which was true, so it showed B. The order matters: always test the highest band first.

Tip: You can put a calculation inside an IF, not just text. For example =IF(B2>100, B2*0.9, B2) gives a 10% discount only when the amount is over 100, and leaves it unchanged otherwise.

Watch out: In a nested IF, count your closing brackets at the end — you need one ) for every IF you opened. Newer Excel also offers IFS, which avoids the pile of brackets, but plain nested IF works everywhere.

Q. What does =IF(A1>10, "Big", "Small") show when A1 contains 4?

Answer: The test A1>10 is false because 4 is not greater than 10, so IF shows the false answer, Small.

✍️ Practice

  1. Put the numbers 30, 55, 80 in column B and write an IF in column C that shows Pass for 50 or more.
  2. Use a nested IF to grade the same scores as A (80+), B (50–79) or C (below 50).

🏠 Homework

  1. Make a list of six exam scores and use IF to label each as Pass or Fail. Then upgrade your formula to a nested IF that gives A, B or C grades instead.
Want to learn this with a mentor?

CodingClave runs guided, project-based training (28-day, 45-day & 6-month batches).

Explore Training →