How to If This And That in Excel
Learn multiple Excel methods to create “if this AND that” logic with step-by-step examples, real-world applications, and practical tips.
How to If This And That in Excel
Why This Task Matters in Excel
In day-to-day analysis, very few decisions hinge on a single factor. More often you need to test several conditions at once before you can declare success, raise a flag, or trigger a workflow. The classic “if this AND that” test is the building block for payroll eligibility rules, sales commission tiers, quality-control pass/fail checks, and hundreds of other business processes.
Imagine an HR analyst confirming whether an employee qualifies for a bonus only when performance is Excellent and tenure is more than two years. In inventory management, a planner might release a purchase order if stock on hand is below the reorder point and vendor lead-time is less than seven days. Financial controllers approve expenses when the amount is below a threshold and the correct cost center appears on the report. Each example demands simultaneous checks—any missing piece invalidates the outcome.
Excel is uniquely suited to these compound decisions for several reasons. First, the grid makes underlying data visible, so logic errors surface quickly. Second, built-in logical functions such as AND, OR, IF, and newer tools like IFS and SWITCH let you assemble sophisticated rules without writing code. Third, Excel connects these logical tests to downstream features—conditional formatting, data validation, Power Query filters, or even automated emails through Power Automate—so “if this AND that” becomes the launching pad for larger solutions.
Failing to master multiple-criteria tests has consequences. Analysts risk paying bonuses to ineligible employees, releasing inaccurate financial statements, or authorizing shipments that cannot be filled. Manually eyeballing each line for two or three conditions is slow, error-prone, and impossible at scale. In contrast, embedding clear logical tests in formulas ensures every record meets the same standard, bolstering governance and saving hours of repetitive checking. Finally, understanding compound logic dovetails with broader Excel skills such as lookup formulas (which often include multiple criteria), dashboard indicators, and even VBA or Power BI expressions built on similar foundation.
Best Excel Approach
The most reliable method for “if this AND that” logic combines the IF function with the AND function:
=IF(AND(logical_test1, logical_test2), value_if_true, value_if_false)
Why this pairing? IF handles the branching decision—what to return when the entire condition is met versus when it is not—while AND evaluates whether all supplied tests are simultaneously TRUE. This modular approach keeps formulas readable, scales to up to 255 tests, and works in every desktop, web, and mobile edition from Excel 2007 onward.
Use this method whenever you need a single outcome dependent on several discrete checks. It requires no special setup: just ensure source cells contain recognizable data types (numbers, dates, text). Under the hood, AND scans each logical_test. Only if every test resolves to TRUE does AND return TRUE to the IF statement, which then releases value_if_true.
Alternative approaches appear in specific contexts:
=IFS(condition1, result1, condition2, result2, TRUE, fallback)
IFS is elegant when you have cascading tiers, but it stops evaluating once one condition is TRUE; therefore, it is better for “if this OR that” chains than strict “AND” logic.
=IF((test1)*(test2), value_if_true, value_if_false)
Multiplying Boolean tests exploits Excel’s TRUE=1, FALSE=0 coercion. It is concise and performant in large arrays, especially with SUMPRODUCT, but sacrifices readability for beginners.
Parameters and Inputs
-
logical_test1, logical_test2, …
- Accept any expression that returns TRUE or FALSE: direct cell comparisons (A2 ≥ 500), text matches (B\2=\"Approved\"), functions such as ISBLANK, WEEKDAY, or COUNTIF results.
- Mixed data types yield #VALUE! errors, so ensure numbers are numeric, dates are date-serials, and text comparisons use consistent case when using the case-sensitive EXACT function.
-
value_if_true
- Can be a constant, a text label, a number, a cell reference, or even another formula.
- If omitted, IF returns zero, which may confuse readers; it is best practice to supply an explicit value such as \"\" for a blank.
-
value_if_false
- Same options as above.
- Consider an explicit message such as \"Check criteria\" instead of leaving the cell blank—better for audit trails.
Optional Concerns
- Range references must not include entire columns in extremely large workbooks because that slows recalculation.
- Wrap text-heavy outputs in quotation marks and escape any embedded quotes with double double-quotes (\"\").
- To guard against empty input cells, include a preliminary test such as IF(COUNTA([A2:C2])<3, \"\", …) before the AND.
- Array formulas combined with IF and AND behave differently in legacy Ctrl-Shift-Enter mode versus the modern Dynamic Array engine; verify version compatibility.
Step-by-Step Examples
Example 1: Basic Scenario – Pass/Fail Exam
You administer a certification exam where participants need a score of 70 or higher and must attend at least 90 percent of classes to pass. Your data begins in row 2:
| A | B | C |
|---|---|---|
| Name | Exam Score | Attendance % |
Enter these sample values:
- A2: “Jordan”
- B2: 85
- C2: 88
Step-by-step:
- Select D2 and enter the label “Result” for clarity.
- In D3 type:
=IF(AND(B2>=70, C2>=90), "Pass", "Fail")
-
Press Enter. The formula evaluates B2 ≥ 70 → TRUE and C2 ≥ 90 → FALSE. Because AND requires all tests to be TRUE, the overall result is FALSE, so IF returns “Fail”.
-
Copy the formula down. As more rows fill, each student’s status updates instantly.
Why it works: Numeric comparisons produce Boolean outcomes. AND demands both TRUE results. A single FALSE flips the verdict.
Variations:
- Switch attendance to “greater than 85” as policies change.
- Change the “Pass” output to a numerical bonus (e.g., 100) if you will later add totals.
- Nest this within conditional formatting to highlight failing rows in red.
Troubleshooting: If Excel displays #VALUE!, ensure attendance is numeric; percent signs in manually typed cells may be stored as text—convert with Value or multiply by 1.
Example 2: Real-World Application – Inventory Reorder Decision
A supply chain analyst wants to flag items that need immediate reorder when Quantity on Hand is below Reorder Point and Supplier Lead-Time is fewer than 10 days (otherwise order from a backup vendor). Data layout:
| A | B | C | D |
|---|---|---|---|
| SKU | On Hand | Reorder Point | Supplier Lead-Time |
Populate rows 2-6 with varied numbers. Then:
- Insert column E titled “Action”.
- In E2 enter:
=IF(AND(B2 < C2, D2 < 10), "Order from Primary", "Hold / Secondary")
- Copy downward.
Explanation:
- B2 < C2 confirms inventory is below threshold.
- D2 less than 10 ensures quick replenishment.
- When both TRUE, “Order from Primary”; otherwise defer.
Integration:
- Combine with Power Query to create an automatic Purchase Order list.
- Create a PivotTable summarizing how many SKUs qualify under each vendor.
- Use cell-linked slicers to adjust the 10-day threshold on the fly.
Performance: With tens of thousands of SKUs this formula is efficient because AND performs simple numeric checks. Avoid volatile functions like TODAY in this context, which would force frequent recalc.
Example 3: Advanced Technique – Multi-Layered Compliance Check with Dynamic Arrays
A compliance officer must confirm transactions meet three simultaneous rules: Amount is below 5 000, Transaction Date falls inside the current fiscal year, and Counterparty is on the Approved List stored in the named range ApprovedVendors. The officer also wants a live list of compliant transactions without manual filters.
Data layout:
| A | B | C | D |
|---|---|---|---|
| ID | Amount | Date | Vendor |
Step-by-step:
- Define ApprovedVendors as [F2:F100] containing valid vendors.
- Create another named formula FiscalStart:
=DATE(YEAR(TODAY()),7,1) 'Fiscal year starts July 1
and FiscalEnd:
=DATE(YEAR(TODAY())+1,6,30)
- In E2 enter:
=IF(AND(B2<5000, C2>=FiscalStart, C2<=FiscalEnd, COUNTIF(ApprovedVendors, D2)>0), "Compliant", "Review")
- For a dynamic array listing only compliant rows, select G1 and type:
=FILTER(A2:D100, (B2:B100<5000)*(C2:C100>=FiscalStart)*(C2:C100<=FiscalEnd)*(COUNTIF(ApprovedVendors, D2:D100)>0) )
Why it works:
- COUNTIF returns ≥ 1 when vendor exists in the list, which AND accepts as TRUE.
- The multiplication trick inside FILTER evaluates each criterion across the entire range, coercing TRUE to 1 and FALSE to 0. Only rows where the product equals 1 pass the filter.
Edge cases and error handling:
- If no rows meet all conditions, FILTER throws #CALC!. Wrap with IFERROR to present “None”.
- DATE comparisons rely on proper serial numbers—text-typed dates break logic. Use Data Validation to restrict entry to dates.
Optimization: Store FiscalStart and FiscalEnd in helper cells so finance can adjust fiscal calendars without editing formulas. This separates logic from configuration.
Tips and Best Practices
- Expose criteria in dedicated cells (e.g., Threshold, Lead-Time) and point formulas to those cells. It simplifies future changes and reduces risk of hard-coded values.
- Document your logic with comments or the N function:
=IF(AND(B2< C2, N("Inventory test")), …)
The comment inside N does not affect calculation but aids auditors.
3. Use indentation in the formula bar (Alt+Enter) when writing long AND chains, enhancing readability.
4. Combine logical tests with conditional formatting icons to create immediate visual dashboards (green check only when all conditions met).
5. Avoid nesting more than three levels of IF; complex rules are clearer when broken into helper columns, each testing one criterion, with a final column combining them through AND.
6. For very large datasets, array-based multiplication (test1*test2) inside SUMPRODUCT or FILTER outperforms repetitive AND functions in each row.
Common Mistakes to Avoid
- Mixing data types: comparing text \"5000\" with numeric 5000 returns FALSE. Convert with VALUE or ensure cells are formatted correctly.
- Using absolute instead of relative references when copying formulas; locking B$2 instead of B2 freezes the test on a single row and misclassifies others.
- Forgetting that AND ignores blank cells treated as FALSE. Include ISNUMBER or LEN tests if blanks should be neutral rather than failing the whole condition.
- Overlooking operator precedence in compound numeric logic; wrapping each test in parentheses avoids ambiguous results.
- Hard-coding today’s date instead of using TODAY(), causing formulas to age and silently fail as time passes.
Alternative Methods
| Method | Best For | Pros | Cons |
|---|---|---|---|
| IF + AND | Universal row-by-row checks | Simple, readable, supported everywhere | Slightly verbose with many conditions |
| Boolean multiplication (test1*test2) | Array aggregation in SUMPRODUCT/FILTER | Concise, performant | Less intuitive for new users |
| IFS function | Cascading OR logic | No nesting depth limit, clean syntax | Evaluates until first TRUE, not ideal for strict AND |
| Power Query Conditional Column | Data cleansing batches | GUI driven, no formulas in grid | Requires refresh, not real-time |
| VBA or Office Scripts | Complex processes with loops | Automate multi-step workflows | Requires programming skill |
Choose IF + AND for most worksheet formulas. Adopt Boolean multiplication in large array contexts. Switch to Power Query if you need a static dataset transformation rather than live calculation.
FAQ
When should I use this approach?
Deploy IF + AND whenever an output must depend on multiple independent conditions that all need to be true. Typical triggers include compliance checks, dual approval workflows, and compound discount rules.
Can this work across multiple sheets?
Yes. Reference external ranges directly, for example:
=IF(AND(Sheet1!B2 >= Sheet2!$B$1, Sheet1!C2 = Sheet2!$C$1), "OK","Out")
Keep sheet names short and use named ranges to avoid long strings.
What are the limitations?
AND allows up to 255 logical tests. Beyond that, break criteria into groups or shift to SUMPRODUCT. Very large volatile formulas can slow recalc; consider helper columns.
How do I handle errors?
Wrap the entire IF inside IFERROR to catch unexpected #N/A or #VALUE!:
=IFERROR(IF(AND(...),"Good","Bad"),"Input Error")
Alternatively test inputs first (e.g., ISNUMBER) before feeding them to AND.
Does this work in older Excel versions?
IF and AND exist since the 1990s, so compatibility back to Excel 97 is strong. Dynamic arrays like FILTER require Microsoft 365, but core IF + AND works everywhere.
What about performance with large datasets?
Row-level IF + AND formulas recalculate quickly, but array formulas scanning entire columns can bog down. Use Excel Tables so ranges automatically resize without referencing full columns, and disable unnecessary volatile functions.
Conclusion
Mastering “if this AND that” logic unlocks a cornerstone of analytical decision-making in Excel. From simple pass/fail tests to elaborate compliance filters, the combination of IF and AND (plus alternative Boolean tactics) creates robust, transparent, and scalable rules. This skill not only safeguards data quality but also integrates with charts, dashboards, and automation tools across the Office ecosystem. Practice the examples, adopt the best practices, and you’ll soon deploy compound logic confidently in any workbook scenario.
Related Articles
How to Show the 10 Most Common Text Values in Excel
Learn multiple Excel methods to list the 10 most frequent text values—complete with step-by-step examples, business use cases, and expert tips.
How to Abbreviate Names Or Words in Excel
Learn multiple Excel methods to abbreviate names or words with step-by-step examples and practical applications.
How to Abbreviate State Names in Excel
Learn multiple Excel methods to abbreviate state names with step-by-step examples, professional tips, and real-world applications.