How to Countifs With Multiple Criteria And Or Logic in Excel

Learn multiple Excel methods to combine AND and OR logic with COUNTIFS, SUM, SUMPRODUCT and dynamic array techniques. Includes step-by-step examples, troubleshooting tips and real-world use cases.

excelformulaspreadsheettutorial
13 min read • Last updated: 7/2/2025

How to Countifs With Multiple Criteria And Or Logic in Excel

Why This Task Matters in Excel

Every business that tracks information in rows and columns eventually asks the question, “How many records meet these exact conditions?” Counting rows is one of the most common summary operations performed in Excel, and the task becomes more interesting when the criteria are not simply stacked (AND logic) but mixed (AND combined with OR logic).

Imagine a sales manager who needs to know how many orders were either larger than 10 000 USD or placed by strategic customers and, at the same time, were shipped within the current quarter. A recruiter may want to count the number of applicants whose skills include either “Python” or “R” while their expected salary is below 90 000 USD. A compliance analyst may have to count transactions that are either flagged as “High Risk” or handled by specific agents and occurred after a certain date.

These everyday scenarios cut across industries—sales, finance, HR, supply-chain, healthcare, education—because making informed decisions relies on instantly spotting records that satisfy nuanced rules. Excel is exceptionally well-suited for this work because it places a formula engine, filters, and pivot capabilities directly on your desktop. Once you master combining COUNTIFS (built for multiple AND criteria) with OR logic, you gain the power to produce one-click dashboards, trigger alerts, feed KPIs, and comply with audit requirements—all without repeating manual filters or exporting data to other tools.

Not understanding how to mix AND and OR logic leads to brittle workbooks. Users often rely on manual filters, helper columns, or copy-paste steps that break whenever the source data changes. Worse, they may misinterpret results because they think a COUNTIFS formula is applying OR matching when, by definition, COUNTIFS applies AND across criteria. Mastering the techniques in this tutorial helps you avoid these traps, speeds up analysis, and deepens your overall Excel proficiency.

Best Excel Approach

The optimal way to apply AND + OR logic is to keep COUNTIFS for what it does best—handle multiple AND criteria—and then use a wrapper such as SUM, SUMPRODUCT, or a dynamic array to bolt on the OR portion. In other words:

  1. Break the OR logic into separate COUNTIFS blocks.
  2. Wrap those blocks inside a function that adds (or otherwise combines) the individual counts.

For most users on Excel 2010 and later, the simplest, fastest, and easiest to audit method is:

=SUM(
  COUNTIFS(range1,criteria_set1,range2,criteria_set2,...),
  COUNTIFS(range1,other_criteria_set1,range2,criteria_set2,...)
)

Each COUNTIFS line obeys AND logic internally, while the SUM adds the independent counts together, delivering OR behavior.

When your OR conditions occur within the same field (for example, “Region is North or South”), you can shorten the code with SUMPRODUCT or, in Microsoft 365, with the FILTER + COUNTA combination. SUMPRODUCT avoids double-counting when rows meet more than one OR condition and you want a distinct count. FILTER produces an array of the rows that meet complex logic, which makes the workbook easier to inspect.

'Handles overlap without double-counting
=SUMPRODUCT( ( (region_range="North") + (region_range="South") ) * (status_range="Open") )

'Dynamic array alternative
=COUNTA( FILTER( id_range, ( (region_range="North") + (region_range="South") ) * (status_range="Open") ) )

Choose SUM + COUNTIFS when the risk of overlapping criteria is small or when you want to count overlaps twice. Choose SUMPRODUCT or FILTER for distinct counts, advanced spill ranges, or when you prefer a single-cell solution.

Parameters and Inputs

  • Counting Range(s) – The ranges fed to COUNTIFS, SUMPRODUCT, or FILTER must be equal in size and shape. Typical data types are text, numbers, or dates.
  • Criteria – Text strings, numbers, cell references, or dynamic array constants wrapped in brackets such as [\"North\",\"South\"]. COUNTIFS evaluates each criterion as “equals” unless you supply a comparison operator in the string.
  • OR Groups – Each OR cluster requires its own COUNTIFS or its own expression inside SUMPRODUCT/FILTER. Keep groups conceptually isolated to avoid confusion.
  • Date Criteria – Store dates as real Excel dates, never as text, and reference a cell like [$G$2] rather than hard-coding \"1/1/2024\" so the workbook adapts easily.
  • Wildcards – Use \"ABC*\" or \"text\" inside text criteria to match partial strings.
  • Overlaps – Decide whether overlapping records (rows that satisfy more than one OR sub-rule) should be counted once or multiple times. This drives whether you adopt SUM + COUNTIFS (counts duplicates) or SUMPRODUCT/FILTER (distinct counts).
  • Empty Cells – COUNTIFS ignores blank criteria ranges. Explicitly handle blanks with criteria \"<>\" or use the ISBLANK function in a helper column when blanks carry meaning.

Step-by-Step Examples

Example 1: Basic Scenario – Counting Orders from Two Regions in a Date Window

Data setup
Place this small sample in [A1:D11]:

OrderIDRegionAmountOrderDate
1001North8 5002023-10-05
1002South12 3002023-10-08
1003East9 9002023-11-02
1004North15 2002023-11-18
1005West6 5002023-11-25
1006South13 7002023-12-03
1007East21 9002023-12-09
1008North7 1002023-12-20
1009South5 2002023-12-28
1010West11 4002024-01-05

Goal: Count orders placed in Q4-2023 (October through December) and whose region is either North or South.

Step-by-step:

  1. In [G2] enter start date = 2023-10-01; in [G3] enter end date = 2023-12-31. Name them Start_Q4 and End_Q4 via the Name Box for easier reading.
  2. In [G5] enter the formula below:
=SUM(
  COUNTIFS( B2:B11, "North", D2:D11, ">="&Start_Q4, D2:D11, "<="&End_Q4),
  COUNTIFS( B2:B11, "South", D2:D11, ">="&Start_Q4, D2:D11, "<="&End_Q4)
)

Result: 5 (orders 1001, 1002, 1004, 1006, 1008).

Why it works: Each COUNTIFS block picks a single region but the same date window. SUM then adds the two counts, producing OR logic for the region field.

Common variations:

  • Swap hard-coded text with cell references so users can change regions.
  • Insert wildcards like \"N*\" to group multiple regions that start with N.

Troubleshooting: If dates come back incorrect, ensure column D is stored as real dates. Use =ISTEXT(D2) in a spare column to verify.

Example 2: Real-World Application – HR Candidate Pipeline

Scenario: An HR analyst maintains a list of applicants with columns: Name, Primary Skill, Secondary Skill, Expected Salary, and Stage. They need to know how many candidates possess either Python or R in either skill column and have expected salary less than 90 000 USD and are at stage \"Interview\".

Sample structure in [A1:E20] (only headers shown for brevity). Let:

  • [A] Name
  • [B] PrimarySkill
  • [C] SecondarySkill
  • [D] ExpectedSalary
  • [E] Stage

Because the OR logic spans two separate columns, SUM + COUNTIFS is still viable but may duplicate candidates that list both Python and R somewhere in columns B or C. HR wants a distinct count. SUMPRODUCT prevents double-counting:

=SUMPRODUCT(
  --( (B2:B20="Python") + (B2:B20="R") + (C2:C20="Python") + (C2:C20="R") > 0 ),
  --( D2:D20 < 90000 ),
  --( E2:E20="Interview" )
)

Explanation of each term:

  1. (B2:B20="Python") + … returns arrays of 1s and 0s; their sum per row is greater than 0 if any of the four checks is true.
  2. -- coerces TRUE/FALSE to 1/0.
  3. Multiplying the three Boolean columns retains 1 only when all AND conditions are true per row.
  4. SUMPRODUCT adds the resulting 1s.

The analyst can drop new data rows and immediately see the pipeline number without refreshing anything.

Integration tips: Feed this result into a KPI card on a dashboard sheet. Combine with conditional formatting to highlight new high-demand candidates. For large lists (thousands of rows), set data to an Excel Table so the ranges resize automatically. SUMPRODUCT handles tables gracefully when you write structured references.

Performance: SUMPRODUCT over tens of thousands of rows remains fast on modern hardware. If the list reaches hundreds of thousands of rows, consider filtering the table first or using Power Pivot measures instead.

Example 3: Advanced Technique – Dynamic Arrays and Spill Ranges

Office 365 subscribers have dynamic arrays. Suppose you track help-desk tickets with columns: TicketID, Agent, Priority, Status, DateClosed. Management wants the distinct count of tickets that are either Priority \"High\" or \"Urgent\", and Status \"Closed\", and DateClosed during the current month. The admin also wants to quickly review the TicketIDs that meet the criteria rather than just the total.

  1. Add a named formula FirstOfMonth = =EOMONTH(TODAY(),-1)+1.
  2. Add a named formula LastOfMonth = =EOMONTH(TODAY(),0).
  3. In a cell on your dashboard, type:
=LET(
  IDs,  A2:A5000,
  Pri,  C2:C5000,
  Stat, D2:D5000,
  Close, E2:E5000,
  Filtered,
     FILTER(
        IDs,
        ( (Pri="High") + (Pri="Urgent") ) * (Stat="Closed") *
        (Close>=FirstOfMonth) * (Close<=LastOfMonth)
     ),
  COUNTA(Filtered)
)

The formula:

  • Uses LET to store intermediate arrays, improving readability and speed.
  • FILTER returns an array (spill range) of TicketIDs matching the compound logic.
  • COUNTA around FILTER produces the count.
  • Place the formula without COUNTA in another cell to see the TicketIDs themselves—hugely helpful during audits.

Edge handling: If no tickets match, FILTER throws #CALC!. Wrap it with IFERROR to display 0 or a custom message:

=IFERROR( COUNTA(Filtered), 0 )

This advanced pattern is faster, less error-prone, and self-documenting because the spill range visually shows which records qualify.

Tips and Best Practices

  1. Name Important Ranges – Friendly names like SalesRegion and StartDate make formulas self-explanatory.
  2. Keep OR Criteria in Vertical List – For long OR lists, place the criteria vertically and reference them with the COUNTIF + SUMPRODUCT combination using structured references.
  3. Avoid Hard-Coding Dates and Numbers – Store thresholds in control cells so business users can tweak logic without editing formulas.
  4. Document Overlap Policy – Add cell comments indicating whether overlapping records are counted once or multiple times. Saves confusion later.
  5. Leverage Excel Tables – Convert raw data to a Table (Ctrl + T). Structured references are immune to row insertions and reduce range mismatches.
  6. Audit with Helper Columns – During development, create temporary Boolean helper columns to show which rows satisfy each criterion. Remove or hide after testing.

Common Mistakes to Avoid

  1. Assuming COUNTIFS Implements OR Logic
    COUNTIFS always applies logical AND across criteria sets. If you write COUNTIFS(Region,"North",Region,"South") you will get zero because no single row can be both. Solution: split into separate COUNTIFS formulas.

  2. Mismatched Range Sizes
    COUNTIFS will silently return #VALUE! if criteria ranges differ in length. Always select from the header row down equally, or use Tables.

  3. Double-Counting Overlaps without Realizing
    When you SUM multiple COUNTIFS blocks, rows that satisfy multiple OR rules increment each block. Decide whether this is desired. Use SUMPRODUCT/FILTER for distinct counts.

  4. Using Text Dates
    Dates typed as \"2024-01-15\" but stored as text cause comparisons to fail. Confirm with =ISTEXT or check left-alignment. Convert with DATEVALUE or Text to Columns.

  5. Ignoring Case Sensitivity in FIND/SEARCH
    When you embed SEARCH to detect substrings inside COUNTIFS, remember SEARCH is not case-sensitive. If case is important, use FIND.

Alternative Methods

MethodProsConsBest For
SUM + COUNTIFSSimple, readable, backward compatible to Excel 2007Overlaps double-count, formula grows long with many OR termsSmall to medium tasks where duplicates acceptable
SUMPRODUCT Boolean LogicSingle formula, prevents double-count, works in all modern versionsHarder to read, slower on massive rangesDistinct counts, medium datasets
FILTER + COUNTA (Dynamic Arrays)Shows actual records, extremely transparent, fastRequires Microsoft 365 or Excel 2021, not available in older versionsAuditing, interactive dashboards, modern Excel
PivotTable with FiltersNo formulas, point-and-clickRefresh required, summary only, limited OR combinationsQuick ad-hoc analysis
Power Pivot & DAXHandles millions of rows, advanced distinct countsSteeper learning curve, not in all editionsEnterprise datasets, repeatable BI models

Migration strategy: Start with SUM + COUNTIFS, and as requirements grow (distinct counts, millions of rows, refreshing automation) graduate to SUMPRODUCT, then FILTER, and eventually to DAX measures in Power Pivot or Power BI.

FAQ

When should I use this approach?

Use these techniques any time you need to count rows that satisfy nuanced rules: sales pipelines, backlog aging, employee headcount by multi-skill, compliance exceptions, or inventory reconciliations. They shine when criteria span different fields or when rules change frequently.

Can this work across multiple sheets?

Yes. Just qualify the ranges with sheet names, for example Sheet1!B2:B500. If the criteria span identical structures on many sheets, create 3-D references or wrap individual sheet formulas inside another SUM. Alternatively, consolidate data into a single Table to keep formulas short.

What are the limitations?

COUNTIFS cannot use OR logic natively, and its criteria limit is 127 pairs. SUM + COUNTIFS may double-count overlaps. SUMPRODUCT may slow down above 300 000 rows. FILTER requires Microsoft 365. For really large or complex data, pivot tables, Power Pivot, or SQL may be better.

How do I handle errors?

Wrap formulas with IFERROR to trap #N/A, #VALUE!, or #CALC! results. Audit the criteria ranges for mismatched sizes. Check date and number formats. For SUMPRODUCT, confirm that Boolean math does not inadvertently create blanks that evaluate to zero.

Does this work in older Excel versions?

SUM + COUNTIFS and SUMPRODUCT work back to Excel 2007. FILTER, LET, and dynamic arrays require Excel 2021 or Microsoft 365. If you are on Excel 2003 or earlier, COUNTIFS is unavailable; use SUMPRODUCT or consolidate data in Access.

What about performance with large datasets?

Keep ranges in Tables and reference entire columns within the Table so the formula adapts without volatile offsets. Avoid entire column references with SUMPRODUCT; restrict to used rows. Turn off automatic calculation during heavy data loads. On datasets beyond 500 000 rows, migrate to Power Pivot or Power Query for preprocessing.

Conclusion

Combining AND and OR logic for counting records is a foundational skill that unlocks deeper analytics in Excel. By splitting OR conditions into separate COUNTIFS blocks or by embracing SUMPRODUCT and dynamic arrays, you can craft precise, auditable counts that respond instantly to new data. These techniques integrate naturally with Tables, dashboards, and downstream reporting workflows, forming a bridge to more advanced technologies like Power Pivot. Practice the patterns in this tutorial, experiment with your own criteria, and you will move from manual filters to fully automated insights—one formula at a time.

We use tracking cookies to understand how you use the product and help us improve it. Please accept cookies to help us improve.