How to Sumifs With Multiple Criteria And Or Logic in Excel
Learn multiple Excel methods to sum data with multiple criteria that include AND and OR logic. Step-by-step tutorials, real-world examples, and expert tips.
How to Sumifs With Multiple Criteria And Or Logic in Excel
Why This Task Matters in Excel
In virtually every reporting, budgeting, or analytical workbook, you eventually need to add up numbers that meet more than one condition. A finance analyst may want to total revenue for a set of products and a specific quarter, while also allowing for any of several possible regions. A human-resources manager might need to sum training costs for employees who are either in Sales or Marketing and who were hired after 2020. Inventory specialists frequently add up stock levels for items that belong to Category A or Category B and are stored in Warehouse 3.
These scenarios share a pattern: they require AND logic (all mandatory criteria must be met) combined with OR logic (one of several acceptable values is enough). Excel’s classic SUMIFS is designed for AND logic only, so adding OR logic forces you to be a bit creative. Mastering this skill unlocks powerful, reusable formulas that drive dashboards, pivot-style summaries, and automated variance reports without helper columns or manual filtering.
From a business perspective, the ability to embed complex logical rules into a single formula reduces errors, speeds up monthly closes, and empowers non-technical team members to explore “what-if” questions on demand. Without this knowledge you may end up with sprawling helper columns, multiple manual filter steps, or, worse, incorrect aggregations that silently misinform decisions. Learning to combine AND and OR criteria properly also sharpens your understanding of array calculation, dynamic arrays, structured references, and Excel’s newer “spill” behavior, all of which are increasingly valuable in modern Excel workflows.
Best Excel Approach
The go-to solution for summing with AND+OR logic is a two-tier formula:
- Use
SUMPRODUCT(works in every desktop version) or theSUM+FILTERcombination (modern Microsoft 365) to introduce OR logic. - Feed the resulting filtered range into the final summation.
Why these approaches?
SUMPRODUCThandles array operations in a single cell, respects AND and OR boolean math, and does not require entering as an old-style CSE array formula.SUM+FILTERis fast, readable, and automatically “spills” the filtered rows, then sums them—all without evaluation quirks.
SUMIFS alone is not sufficient because each criterion you add is automatically AND-ed. To OR values you must either combine several SUMIFS calls or push the OR test inside an array calculation.
Recommended syntax (modern Excel):
=SUM( FILTER( Amounts ,
(Region="South") * ((Category="A") + (Category="B")) ) )
Legacy compatible syntax:
=SUMPRODUCT( (Region="South") * ((Category="A") + (Category="B")) * Amounts )
Explanation of parameters:
Amounts– numeric range to add up(Region="South")– mandatory criterion (TRUE/FALSE array)((Category="A") + (Category="B"))– OR criterion; addition treats TRUE as 1 so any match produces 1- Multiplication
*forces AND logic between tests.
Choose SUMPRODUCT if colleagues use Excel 2010–2016 or if you prefer single-cell results without spill behavior. Choose SUM + FILTER for the clearest syntax and fastest recalc in Microsoft 365.
Parameters and Inputs
- Sum Range (numeric) – The cells you actually want to total, e.g. [D2:D1000]. Values must be numbers or numeric text; blanks and text are ignored.
- Criteria Ranges (text, numbers, dates) – One or more same-sized ranges that contain values you test. Each must align row-for-row with the sum range.
- Criteria Expressions – Logical comparisons such as
Region="South"orHireDate>DATE(2020,12,31). They may reference constants, cells, dynamic arrays, or spills. - OR Lists (arrays or ranges) – Sets of acceptable values, e.g. [\"A\",\"B\",\"C\"] or [F2:F4]. Use the plus symbol inside
SUMPRODUCT, orISNUMBER(MATCH()), or the implicit array logic thatFILTERaccepts. - Optional Boolean Operators –
*for AND,+for OR withinSUMPRODUCT. Parentheses are critical to enforce proper order. - Data Preparation – Remove extra spaces, ensure consistent spelling, convert numbers stored as text, and format dates as true Excel dates.
- Edge Case Handling – Watch for empty OR lists, mismatched range sizes (returns
#VALUE!), or entire criteria columns filled with blanks (results are zero). UseIFERROR()orN()to coerce blanks if needed.
Step-by-Step Examples
Example 1: Basic Scenario
Imagine a simple sales table:
| Row | Region | Category | Amount |
|---|---|---|---|
| 2 | South | A | 1 250 |
| 3 | North | B | 980 |
| 4 | South | B | 1 775 |
| 5 | East | A | 650 |
| 6 | South | C | 2 100 |
Goal: Sum sales where Region is South AND Category is A or B.
-
Set Named Ranges to make the formula self-documenting:
Region→ [B2:B6]Category→ [C2:C6]Amounts→ [D2:D6]
-
Enter formula (SUMPRODUCT version):
=SUMPRODUCT( (Region="South") * ((Category="A") + (Category="B")) * Amounts )
-
Breakdown:
Region="South"returns [TRUE, FALSE, TRUE, FALSE, TRUE].Category="A"returns [TRUE, FALSE, FALSE, TRUE, FALSE].Category="B"returns [FALSE, TRUE, TRUE, FALSE, FALSE].- Adding the two category arrays produces [1,1,1,1,0].
- Multiplying arrays: [1,0,1,0,1] * [1,1,1,1,0] gives [1,0,1,0,0].
- Final multiplication with
Amountsselects [1 250,0,1 775,0,0]; sum = 3 025.
-
Check result – The formula returns 3 025, matching manual verification (rows 2 and 4).
-
Troubleshooting Variations:
- Category typo (“ b ” with space) will exclude row 3; use
TRIM()or Data Validation. - If you place Categories to OR in cells [F2:F3] you can replace
((Category="A")+ (Category="B"))withISNUMBER(MATCH(Category,$F$2:$F$3,0))for easy maintenance.
- Category typo (“ b ” with space) will exclude row 3; use
Example 2: Real-World Application
Scenario: A company’s budget sheet lists Expense Type, Department, Fiscal Quarter, and Amount across 5 000 rows. Management asks: “What is the total travel expense for either Sales or Marketing in Q2 and Q3 combined?”
Sample headers (row 1):
| A | B | C | D |
|---|---|---|---|
| Expense_Type | Department | Quarter | Amount |
-
Define dynamic named ranges using Excel Tables (Table name:
tblExpense). The formula will then readtblExpense[Department], etc. Tables auto-extend as data grows. -
Store OR Lists:
- Department filter list: in [F2:F3] enter Sales, Marketing.
- Quarter filter list: in [G2:G3] enter Q2, Q3.
-
Modern formula (FILTER + SUM)
=LET(
depts, tblExpense[Department],
qtrs, tblExpense[Quarter],
amts, tblExpense[Amount],
okDept, ISNUMBER(MATCH(depts, F2:F3, 0)),
okQuarter, ISNUMBER(MATCH(qtrs, G2:G3, 0)),
SUM( FILTER( amts, (tblExpense[Expense_Type]="Travel") * okDept * okQuarter ) )
)
-
Explanation:
MATCHprovides flexible OR lists with spill ranges.- Multiplication of booleans imposes AND across Expense_Type, Department OR list, Quarter OR list.
FILTERoutputs only rows meeting all three filters;SUMaggregates results.
-
Why this solves the business question: Management can now tweak the lists (e.g., add Customer Success) and the formula instantaneously updates—a powerful interactive report without VBA or PivotTables.
-
Performance Note: Even with 50 000 rows this formula recalculates in milliseconds on modern hardware because
FILTERworks column-wise and spills a contiguous block directly into memory.
Example 3: Advanced Technique
Scenario: An operations analyst tracks machine downtime in minutes. Columns are Plant, Machine_Group, Downtime_Date, and Minutes. He needs total downtime:
- Plants = Plant1 or Plant2 or Plant4
- Machine_Group = GroupA
- Downtime_Date between 1-Jan-2023 and 30-Jun-2023 OR between 1-Nov-2023 and 31-Dec-2023
(yes, two separate fiscal windows)
Approach: Build compound booleans inside SUMPRODUCT, then wrap in N() to coerce TRUE/FALSE arrays to 1/0.
=SUMPRODUCT(
N(ISNUMBER(MATCH(Plant, {"Plant1","Plant2","Plant4"}, 0))) *
N(Machine_Group="GroupA") *
N( (Downtime_Date>=DATE(2023,1,1)) * (Downtime_Date<=DATE(2023,6,30))
+ (Downtime_Date>=DATE(2023,11,1)) * (Downtime_Date<=DATE(2023,12,31)) ) *
Minutes
)
Key insights:
- The date test uses two AND sub-tests joined by a plus (OR).
- Wrapping in
N()ensures reliable conversion because Excel may treat booleans directly multiplied by arrays inconsistently in older versions. - This formula maintains one pass through all rows, which is significantly faster than adding four separate
SUMIFSresults together. - Error Handling: If any date cell contains text, the comparison returns
#VALUE!; protect with--(ISNUMBER(Downtime_Date))wrapper or cleanse data.
Professional Tips:
- Consider turning the date ranges into parameter cells for easy maintenance.
- For very large datasets, push data into Power Query or Power Pivot, but this single-cell approach is perfect for under 100 000 rows in desktop Excel.
Tips and Best Practices
- Name Your Ranges – Use meaningful names or Excel Tables so your OR logic is readable (
Region="West") rather than cryptic letter coordinates. - Bracket Aggressively – Always surround OR blocks with parentheses;
(A="x")+(A="y")must be evaluated before AND multiplication. - Leverage LET() – Break complex formulas into variables for clarity and one-time calculation of repeated expressions.
- Store OR Lists in Cells – Use
MATCH()against a spill range instead of hard-coding values. It reduces formula edits and supports dropdown-driven dashboards. - Watch Data Types – Dates stored as text, mixed number formats, or trailing spaces will silently cause criteria mismatches. Apply
VALUE()orTRIM()as pre-clean steps. - Audit with FILTER() – When results look off, temporarily replace
SUMPRODUCTwithFILTERto see exactly which rows pass the logic gate—a powerful debugging trick.
Common Mistakes to Avoid
- Mismatched Range Sizes –
SUMPRODUCTreturns#VALUE!if your boolean arrays differ in length. Verify all ranges are the same rows. - Forgetting Parentheses – Writing
A="x"+A="y"instead of(A="x")+(A="y")triggers “Type mismatch” or, worse, a silently wrong result (addition has higher precedence than equality). - Using Commas Instead of Multiplication in Older Excel – In some locales commas separate arguments inside
SUMPRODUCT; you must multiply booleans, not separate them by commas, or they are treated as separate arrays to sum individually. - Hard-Coding OR Values Everywhere – Embedding
"North","East","West"inside the formula bloats it and hides logic. Externalize to cells and useMATCH(). - Not Testing for Blank Cells – Blank criteria may evaluate as zero and accidentally filter out every row. Use
LEN()checks or default the blank logic to TRUE.
Alternative Methods
| Method | Excel Version | Pros | Cons | Ideal Use |
|---|---|---|---|---|
Multiple SUMIFS added together | 2007+ | Simple if only 1 OR list | Quickly becomes verbose, heavy recalc | Two or three OR items, small sheets |
SUMPRODUCT Boolean Math | 2003+ | Single cell, handles any logic | Syntax dense, easy to mis-parenthesise | Cross-version sharing, power users |
SUM + FILTER | 365 | Clean, readable, spills filtered list | Requires Microsoft 365, spills extra cells | Modern workbooks, dashboards |
Helper Column for OR Flag + SUMIFS | All | Easiest for beginners | Adds columns, manual updates | Shared models with less-technical users |
| Power Pivot DAX Measure | 2010+ (Pro) / 365 | Handles millions of rows, sliceable | Needs Data Model knowledge | Enterprise BI, Power BI integration |
Performance: SUMPRODUCT and FILTER both process entire columns but only evaluate once per recalc. Multiple SUMIFS runs a separate pass for each OR value, which may be slower at scale. However, on fewer than 100 000 rows the difference is negligible.
FAQ
When should I use this approach?
Use AND+OR summing when your report calls for totals constrained by multiple simultaneous rules—especially when at least one rule involves a list of acceptable values. It is perfect for regional roll-ups, multi-period comparisons, or scenario filtering without resorting to PivotTables.
Can this work across multiple sheets?
Yes. Qualify ranges with sheet names (Sheet2!A:A) or use 3D references inside SUMPRODUCT. Alternatively, consolidate ranges via CHOOSE(): =SUMPRODUCT( (CHOOSE([1,2],Sheet1!B:B,Sheet2!B:B)="East") * … ). For 365 users, stack sheets with VSTACK() then apply a single FILTER().
What are the limitations?
SUMPRODUCT on entire columns in pre-2019 builds can be slow with very large datasets. Additionally, array math cannot handle non-contiguous ranges. Complex OR lists inside SUMPRODUCT also raise the risk of writing mis-parenthesised formulas. If you need grouping or drill-down, consider a PivotTable or Power Pivot.
How do I handle errors?
Wrap numeric arrays with IFERROR(range,0) to ignore #DIV/0! or #N/A. For booleans, --NOT(ISERROR(criteria)) can pre-validate. In FILTER, supply an optional “if empty” argument: FILTER(data, criteria, 0) which returns 0 instead of #CALC!.
Does this work in older Excel versions?
SUMPRODUCT works in Excel 2003 onward without CSE entry, making it the most backward-compatible. FILTER, LET, and dynamic arrays require Microsoft 365 or Excel 2021. If distributing to older users, stick to SUMPRODUCT or helper columns.
What about performance with large datasets?
On 50 000-100 000 rows, both SUMPRODUCT and FILTER respond instantly. Beyond that, keep formulas off entire columns (use structured tables), avoid volatile functions, and consider pushing data into Power Query or the Data Model where DAX measures calculate more efficiently.
Conclusion
Being able to sum with intricate AND plus OR criteria elevates your analytical capabilities far beyond basic SUMIF. Whether you prefer the universal power of SUMPRODUCT or the elegance of FILTER in modern Excel, the techniques here let you replace cumbersome manual filters and fragile helper columns with rock-solid formulas. Master this skill and you will produce faster, leaner, and more dynamic reports—an essential competency for any Excel professional. Next, experiment with nesting these patterns inside larger models, incorporate user-driven slicers, and explore pivot-oriented alternatives to broaden your reporting toolbox.
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.