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 business spreadsheet, that is how a column decides "Reorder" or "OK", "Late" or "On time", "Over limit" or blank. When one of those status columns is wrong, the cost is real: a stockout because an item was marked OK, or a collections call to a customer who already paid. This guide covers the syntax, multiple conditions, nested IF versus IFS, blank and text traps and error handling, then walks through a complete reorder 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<D2,"Reorder","OK") compares on-hand quantity in C2 with safety stock in D2. The result arguments can be text, numbers, cell references or other formulas, so =IF(C2<D2,D2*2-C2,0) returns a suggested order quantity only when stock is short. 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. "Reorder when stock is below safety stock" and "reorder when stock is at or below safety stock" give different answers on the day the two numbers match. Pick the rule your team actually uses, 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 ship 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<D2,G2<>"Discontinued"),"Reorder","")
=IF(OR(F2="Return",F2="Damaged"),"Inspect","")
The first formula reorders only items that are short and still active. The second flags rows whose status is either Return or Damaged. You can combine the two: =IF(AND(C2<D2,OR(H2="A",H2="B")),"Priority","") picks out short items in the A and B classes only.
Blank cells deserve their own check. In C2<D2, an empty D2 is treated as zero, so an item with no safety stock set will always come back "OK". Put a test for the blank threshold 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.
=IF(B2>=1000,"Tier 1",IF(B2>=500,"Tier 2",IF(B2>=100,"Tier 3","Tier 4")))
Order matters. If you put the >=100 test first, a customer with 1,200 in monthly volume matches it and lands in Tier 3. 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>=1000,"Tier 1",B2>=500,"Tier 2",B2>=100,"Tier 3",TRUE,"Tier 4")
IFS returns #N/A when no condition is met, which is why the final TRUE,"Tier 4" pair acts as a catch-all. If a customer or a branch office still opens your file in Excel 2016, IFS cells show #NAME?, so keep nested IF for files that leave the building. When the tiers change every quarter, 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 an ERP or a marketplace portal. 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("frozen",B2)),"Frozen","Ambient").
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 growth-rate column readable when last month's number is missing. On a status or reconciliation 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 reorder sheet at Crestview Foods
Crestview Foods distributes frozen and shelf-stable products to grocery stores across three states. Every Monday morning the purchasing coordinator exports item-level stock from the warehouse system to Excel and decides what to reorder. The file has item number in A, description in B, on-hand quantity in C, safety stock in D, average weekly shipments in E and status (Active or Discontinued) in G. There are about 320 items. Until last quarter, she compared the columns by eye and shaded rows yellow. One busy week she missed a case-pack of frozen burritos and the item was out for three days.

She starts by writing the rule in plain sentences, in the order it should be checked. Skip discontinued items. If safety stock is blank, show "No target". If on-hand is not a number, show "Check data". If on-hand is below safety stock, "Reorder". If it is below safety stock plus one week of shipments, "Watch". Otherwise "OK". Writing it this way settles the nesting order: exceptions first, general rules last.
The formula in H2:
=IF(G2="Discontinued","",IF(D2="","No target",IF(NOT(ISNUMBER(C2)),"Check data",IF(C2<D2,"Reorder",IF(C2<D2+E2,"Watch","OK")))))
She fills it down and tests three boundary rows before trusting it. An item with on-hand exactly equal to safety stock should read "Watch", and one exactly at safety stock plus a week of shipments should read "OK". This week four rows returned "Check data". All four had on-hand values like 120 with a trailing space, stored as text. 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,"Reorder"), filters to Reorder and Watch, sorts by supplier and pastes the list into the purchase request for Northgate Supply and the other vendors. Next Monday she only copies column H into the new export. Comparing 320 rows by eye took most of a morning; the formula takes seconds and does not skip a row when the item count grows.
👉 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 tier for large values | 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 $D$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("frozen",B2)),"Frozen",""). 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,"Reorder").
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.
How inline AI handles IF formulas
inline AI opens the workbook and turns a rule you say in plain English, such as "reorder when below safety stock, skip discontinued items", into a working status column, and it finds the rows that would break it, like numbers stored as text. With the AI OS and ARP, items that fall below safety stock trigger a purchase order to the supplier directly, so the Monday export-and-check routine goes away.
Hand your documents and your company’s work to inline AI.
Keep a file open, say what you need, and AI edits it or drafts a new one. Add the company AI OS and AI runs the rest of the work, ERP included.
Book a demo



