Blog
Excel IF Function: Multiple Conditions, Nested IF and IFS
The Excel IF function returns one value when a condition is true and another when it is false. In a gradebook or a budget, that is how a column decides "Pass" or "Fail", "Late" or "On time", "Over budget" or blank. When one of those status columns is wrong, the cost is real: a student marked OK who is actually failing, or a late notice sent home for an assignment that was turned in on time. This guide covers the syntax, multiple conditions, nested IF versus IFS, blank and text traps and error handling, then walks through a complete grade-status sheet.
IF function syntax and comparison operators
=IF(logical_test, value_if_true, value_if_false)
The logical test must evaluate to TRUE or FALSE. =IF(C2>=60,"Pass","Fail") compares the score in C2 with a passing mark of 60. The result arguments can be text, numbers, cell references or other formulas, so =IF(C2<60,60-C2,0) returns how many points a student still needs only when the score is below 60. If you leave the third argument out, Excel shows FALSE when the test fails; use "" if you want a blank cell instead.
Excel has six comparison operators: > greater than, < less than, >= greater than or equal to, <= less than or equal to, = equal to and <> not equal to. The most common logic error is at the boundary. "Pass at 60 or above" and "pass above 60" give different answers for the student who scored exactly 60. Pick the rule in your syllabus, then choose >= or > to match it.
Dates compare the same way because Excel stores them as serial numbers. =IF(E2<TODAY(),"Past due","") flags any due date before today. If a date column was imported as text, the comparison fails silently, so check alignment: real dates and numbers sit on the right of the cell by default, text sits on the left.
Multiple conditions with AND and OR
Put AND or OR inside the logical test when one condition is not enough. According to the Microsoft Learn reference for AND, AND returns TRUE only if all its arguments are TRUE, and text or empty cells inside a referenced range are ignored. OR returns TRUE if any argument is TRUE.
=IF(AND(C2<60,G2<>"Withdrawn"),"Failing","")
=IF(OR(F2="Missing",F2="Incomplete"),"Follow up","")
The first formula flags only students who are below 60 and still enrolled. The second flags rows whose status is either Missing or Incomplete. You can combine the two: =IF(AND(C2<70,OR(B2="P1",B2="P2")),"Priority","") picks out students under 70 in first and second period only.
Blank cells deserve their own check. In C2<60, an empty C2 is treated as zero, so a student with no grades entered yet always comes back as failing. Put a test for the blank cell first and the problem disappears.
Nested IF versus IFS
When you need three or more outcomes, nest one IF inside another. Excel evaluates them left to right and stops at the first test that is TRUE. Excel allows up to 64 nested IF functions, but anything past three or four levels becomes hard to read and harder to fix. Letter grades are the classic case:
=IF(B2>=90,"A",IF(B2>=80,"B",IF(B2>=70,"C",IF(B2>=60,"D","F"))))
Order matters. If you put the >=60 test first, a student with a 95 matches it and gets a D. Put narrow conditions and exceptions first and broad conditions last.
Excel 2019 and later, including Microsoft 365, have the IFS function, which lists condition and result pairs without the stacked parentheses:
=IFS(B2>=90,"A",B2>=80,"B",B2>=70,"C",B2>=60,"D",TRUE,"F")
IFS returns #N/A when no condition is met, which is why the final TRUE,"F" pair acts as a catch-all. If a colleague still opens your file in Excel 2016, IFS cells show #NAME?, so keep nested IF for files you share widely. When the cutoffs change, for example when your department adds plus and minus grades, a small lookup table with an approximate-match VLOOKUP or XLOOKUP is easier to maintain than either formula.
Text, blank cells and IFERROR
Text in a condition goes inside double quotes. A trailing space makes "Done" and "Done " different values, which is common in exports from a learning management system or a student information system. The = comparison is not case-sensitive; wrap the test in EXACT if case matters. Clean imported text with TRIM and CLEAN in a helper column before you test it.
To test for blanks, compare with an empty string, D2="", rather than ISBLANK when the column holds formulas, because a formula that returns "" looks empty but ISBLANK reports FALSE. IF has no wildcard support, so "contains" logic needs SEARCH: =IF(ISNUMBER(SEARCH("lab",B2)),"Lab","Other") sorts assignments by whether their name mentions a lab.
When the formula itself can fail, IFERROR swaps the error for a value you choose. The Microsoft Learn reference for IFERROR lists the errors it catches: #N/A, #VALUE!, #REF!, #DIV/0!, #NUM!, #NAME? and #NULL!. It also treats an empty first argument as an empty string.
=IFERROR((C2-B2)/B2,"-")
That keeps a change column readable when last month's number is missing. On a grade sheet, though, an error usually means bad input, so fix the input rather than hiding it. If only "not found" should be handled, use IFNA, which catches #N/A and lets every other error show.
Worked example: a weekly grade-status sheet
A high school biology teacher with five sections, about 150 students, exports current grades from the gradebook every Friday and decides which families to contact before progress reports. The file has student ID in A, period in B, current grade in C, missing assignments in D and enrollment status (Active or Withdrawn) in G. She keeps the passing mark, 60, in K1 and a 10-point watch margin in K2. Until last quarter, she scanned the columns by eye and shaded rows yellow. One busy week she missed a student who had slipped below 60, and the family first heard about it on the progress report.

She starts by writing the rule in plain sentences, in the order it should be checked. Skip students who have withdrawn. If the grade is blank, show "No grades yet". If the grade is not a number, show "Check data". If the grade is below 60, "Failing". If it is below 70, or the student has three or more missing assignments, "Watch". Otherwise "OK". Writing it this way settles the nesting order: exceptions first, general rules last.
The formula in H2:
=IF(G2="Withdrawn","",IF(C2="","No grades yet",IF(NOT(ISNUMBER(C2)),"Check data",IF(C2<$K$1,"Failing",IF(OR(C2<$K$1+$K$2,D2>=3),"Watch","OK")))))
She fills it down and tests three boundary rows before trusting it. A student at exactly 60 should read "Watch", and one at exactly 70 with no missing work should read "OK". This week four rows returned "Check data". All four had grades like 87 with a trailing space, stored as text after a copy and paste from the gradebook. Replacing the column with =VALUE(TRIM(C2)) in a helper column fixed every one of them.

Finally she counts the result with =COUNTIF(H:H,"Failing"), filters to Failing and Watch, sorts by period and uses the list for the week's parent emails and a short check-in with the school counselor. Next Friday she only copies column H into the new export. Scanning 150 rows by eye took most of a planning period; the formula takes seconds and does not skip a row when a new student enrolls.
👉 VLOOKUP Not Working? How to Fix #N/A, #REF! and #VALUE!
Common IF mistakes and how to fix them
| Symptom | Likely cause | Fix |
|---|---|---|
| Every row returns the same result | Numbers stored as text | Convert with VALUE or Text to Columns |
| FALSE appears in cells | Third argument left out | Add "" as value_if_false |
| Wrong letter grade for high scores | Broad test placed first | Put narrow tests and exceptions first |
| Text match fails | Leading or trailing spaces | Clean with TRIM and CLEAN |
| #NAME? error | Missing quotes, or IFS in Excel 2016 | Quote text, or switch to nested IF |
Two more catch people often. Writing => instead of >= is rejected as an invalid formula. And typing a number result in quotes, such as "0", makes it text, so it drops out of SUM and AVERAGE. When the threshold sits in a single cell, lock it with an absolute reference like $K$1 before filling down, or each row will compare against a different cell.
FAQ
Q. What if I have more than five conditions?
Use IFS in Excel 2019 or later. If the thresholds change often, keep them in a lookup table and use VLOOKUP or XLOOKUP with approximate match, so a change is one edit in the table instead of one in every formula.
Q. Can IF check whether a cell contains certain text?
Not by itself. Combine SEARCH and ISNUMBER inside the test, as in =IF(ISNUMBER(SEARCH("lab",B2)),"Lab",""). Use FIND instead of SEARCH for a case-sensitive match.
Q. Should I use IF to count or total rows that meet a condition?
COUNTIF, COUNTIFS, SUMIF and SUMIFS are simpler. A common pattern is to build the status column with IF, then count it with =COUNTIF(H:H,"Failing").
Q. What is the difference between IFERROR and IFNA?
IFERROR replaces any of seven error types. IFNA replaces only #N/A, so a broken reference still shows #REF! and gets noticed.
inline AI for grade status columns
inline AI opens the gradebook on your PC and turns a rule you say in plain English, such as "failing under 60, watch under 70 or with three missing assignments, skip withdrawn students", into a working status column, and it finds the rows that would break it, like grades stored as text.
Gradebooks and spreadsheets, finished by inline AI in the file itself.
Ask in one sentence for roll-ups, trackers and the cleanup you repeat every week. Your files never leave your computer.




