Excel IF Function With Multiple Conditions: AND, OR, Nested IF and IFS
Use IF with AND and OR, write a nested IF in the right order, switch to IFS or a lookup table, and find why a branch of your formula never fires.
- Excel
- Formulas
- Data Quality

On this page
- How do you use IF with multiple conditions in Excel?
- How do you write a nested IF for three or more outcomes?
- How does IFS replace a nested IF?
- When should you use a lookup table instead of IF?
- Why does my IF formula not work with multiple conditions?
- Does Google Sheets work the same way?
- Where does Glow Reports fit?
- Common questions
You want a column that labels each order Large, Medium or Small, flags the ones that get free shipping, or sets refunds aside. IF does it, but with several conditions the formula grows into a nest of brackets, and one condition in the wrong place makes a whole branch disappear without an error. This guide shows IF with AND and OR, a nested IF in the right order, IFS, and a lookup table that replaces the nest, all on one sample order export. Then the reasons a branch never fires.
How do you use IF with multiple conditions in Excel?
Put AND or OR inside the test of IF. AND returns TRUE when every condition is true, OR when at least one is: labels French orders of 500 or more Microsoft Support.
Here is the sample used in this guide, an order export. Type it in A1:D11.
| Order | Country | Status | Amount |
|---|---|---|---|
| 1001 | France | Paid | 1250 |
| 1002 | Belgium | Paid | 380 |
| 1003 | France | Refunded | 95 |
| 1004 | France | Paid | 640 |
| 1005 | Germany | Paid | 2100 |
| 1006 | Belgium | Cancelled | 410 |
| 1007 | France | Paid | 180 |
| 1008 | Germany | Paid | 999 |
| 1009 | France | Paid | 250 |
| 1010 | Belgium | Paid | 75 |
Free shipping goes to paid French orders of 500 or more. Three conditions, all required, so they go in one AND:
=IF(AND(B2="France",C2="Paid",D2>=500),"Free shipping","")Refunded and cancelled orders leave the report. Either status is enough, so they go in OR:
=IF(OR(C2="Refunded",C2="Cancelled"),"Exclude","Keep")Text tests ignore case, so "paid" matches "Paid". They don't ignore spaces. An export that writes "Paid " with a trailing space fails the test, and how to clean data in Excel shows how to strip it.
How do you write a nested IF for three or more outcomes?
Put a second IF in the "false" part of the first, and test the largest threshold first. Each IF returns as soon as its test is true, so the order of the tests decides the result. Excel accepts up to 64 nested IFs, and Microsoft advises against going anywhere near that Microsoft Support.
Order size tiers: 1,000 or more is Large, 250 or more is Medium, below that Small.
=IF(D2>=1000,"Large",IF(D2>=250,"Medium","Small"))Swap the two tests and the formula still runs, with no error, but Large disappears. labels order 1005, at 2,100, as Medium, because 2,100 passes the first test before the second is ever read. The sample then shows 7 Medium and 0 Large. Microsoft's own example of commission rates fails the same way when the tests run from low to high.
To combine the tiers with the exclusions, put the exclusion first, so a refunded order of 1,250 doesn't come out Large:
=IF(OR(C2="Refunded",C2="Cancelled"),"Exclude",IF(D2>=1000,"Large",IF(D2>=250,"Medium","Small")))How does IFS replace a nested IF?
IFS takes pairs of a test and a result and returns the result of the first true test. It reads like a list, with no closing brackets to count. Add TRUE as the last test to set the default, or IFS returns #N/A when no test is true Microsoft Support.
=IFS(D2>=1000,"Large",D2>=250,"Medium",TRUE,"Small")The order rule stays the same: the first true test wins, so the largest threshold still goes first. IFS takes up to 127 pairs. It exists in Excel 2019 and later and in Microsoft 365. A workbook opened in Excel 2016 shows in its place.
The AR aging report uses the same IFS pattern to sort invoices into 0-30, 31-60 and 61-90 day buckets.
When should you use a lookup table instead of IF?
As soon as the tiers have more than three or four levels, or someone other than you changes the thresholds. Put the thresholds in a small table and look each amount up in it. Changing a tier then means editing a cell, not every formula. Microsoft suggests a lookup in place of complex IF formulas in most cases Microsoft Support.
Type the thresholds in F1:G4, smallest first:
| From | Tier |
|---|---|
| 0 | Small |
| 250 | Medium |
| 1000 | Large |
Then in E2:
=XLOOKUP(D2,$F$2:$F$4,$G$2:$G$4,,-1)The is the match mode: an exact match, or the next smaller item when there is none Microsoft Support. For 640 there is no exact match, so XLOOKUP takes 250 and returns Medium. Without XLOOKUP, does the same, as long as the first column is sorted from smallest to largest. XLOOKUP vs VLOOKUP covers the differences.
Once the column is filled, counts the tiers and sums them, 2,679 for Medium on the sample. COUNTIFS with multiple criteria goes further.
Why does my IF formula not work with multiple conditions?
Usually because an earlier test catches the rows first, because the numbers are stored as text, or because the conditions are chained in a way Excel doesn't read. Excel shows a result in each case, so the error only shows when you count the labels.
- Tests in the wrong order. The first true test wins. Put the largest threshold first, and the exception (refunds, N/A, missing data) before the general rule. A Tech Community thread on an audit template had this exact cause: an N/A branch never fired because an earlier IF had already returned Passed. The fix was to test N/A first.
- Chained comparisons. doesn't test a range. Excel works out to TRUE or FALSE, then compares that logical value with 999, which always gives FALSE. Write instead. A Microsoft Q&A answer gives the same fix Microsoft Q&A.
- Numbers stored as text. In a comparison, Excel treats any text as larger than any number. An amount imported as the text "120" passes and comes out Large. Text numbers sit on the left of the cell, and returns FALSE for them. Convert the column before you label it.
- Numbers in quotes. compares with the text "1000", not the number. Leave numbers without quotes in the test, and only quote the text you return.
- Blank cells. An empty amount counts as 0, so it comes out Small. Test for it first: .
Does Google Sheets work the same way?
Yes. Google Sheets has IF, AND, OR, IFS and XLOOKUP with the same arguments, so every formula above works as written. IFS returns #N/A there too when no test is true Google Docs Editors Help, and XLOOKUP takes the same match mode Google Docs Editors Help.
Text tests in Sheets ignore case as well, and the order rule is the same: the first true test wins.
Where does Glow Reports fit?
Nested IFs work well for one label column on one export. They get harder to trust when the tiers change every quarter, when the same split is needed by country and by month, or when someone else has to check which rule came first.
With Glow Reports, you upload the export as CSV or Excel and ask in plain language. For example: "split orders into Large from 1,000, Medium from 250 and Small, leave out refunds and cancellations, and show the total per tier by month". The AI writes the SQL, builds the charts and drafts the text. The SQL sits under each figure, so you can read the CASE WHEN that does what your nested IF did, check the order of the conditions, and edit it. Reports export to PDF and stay in the workspace. The free plan gives 300 credits once, and a report costs 100 credits.
Common questions
How many IF statements can you nest in Excel?
Up to 64. Past three or four levels, use IFS or a lookup table, because a long nest is hard to read and easy to get wrong without any error showing.
What is the difference between IF and IFS?
IF tests one condition and returns one of two results, so several outcomes need nested IFs. IFS takes several test and result pairs in one function and returns the first true one. IFS needs Excel 2019 or later.
How do I use IF with AND and OR together?
Nest them in the test. returns Yes for French orders that are paid or shipped.
Why does my nested IF always return the same value?
Most often the first test is true for almost every row, so the others are never read. Test the largest threshold first. If every row still returns the same label, check whether the numbers are stored as text.
Can IF check if a cell contains a word?
Not on its own, because IF compares the whole cell. Combine it with SEARCH: finds "refund" anywhere in the cell, in any case.
I am a product engineer and the founder of Glow Reports. I spent more than 6 years building products in tech, data and cybersecurity, for large groups, startups and SMEs. In most organizations I saw data treated as a technical topic, when it drives business decisions. I built the reporting tool I was looking for, so the people who run small and mid-sized organizations can read their own numbers without a data team.
More from El Mehdi BenaneUpload your order export to Glow Reports and ask for totals by order size and month, with the SQL behind each figure so you can check every rule.


