Managing complex datasets often leads to frustration when standard formulas fail to aggregate OR-based criteria efficiently. Typically, analysts track standard funding sources-such as municipal allocations or private donations-using repetitive, bloated addition formulas.
Fortunately, mastering advanced array constants grants you the ability to streamline this process into a single, elegant cell. A key stipulation to remember is that this method assumes criteria are mutually exclusive to avoid double-counting. For instance, to count rows representing "Federal" or "State" green-energy grants, we combine SUM and COUNTIF.
Below, we will dissect this exact formula structure so you can apply it to your own reports.
Excel is an incredibly powerful tool for data analysis, but its default behavior can sometimes feel limiting. One of the most common challenges users face is performing conditional counts with "OR" logic. By default, functions like COUNTIFS are designed around "AND" logic-meaning they only count a row if all specified criteria are met.
But what if you need to count rows that match any of multiple criteria? For instance, how do you count orders where the region is "North" OR the product is "Software"? Or how do you count sales reps who sold either "Apples", "Oranges", or "Pears"?
In this comprehensive guide, we will explore several highly effective methods to count rows matching multiple criteria using "OR" logic, ranging from classic Excel formulas to modern dynamic array functions.
If you need to count rows where a single column matches any of several criteria, the easiest and most elegant solution is combining the SUM and COUNTIF (or COUNTIFS) functions with an array constant.
=SUM(COUNTIF(range, {"criterion1", "criterion2", "criterion3"}))
Normally, COUNTIF takes a single value and returns a single count. However, by wrapping your criteria in curly braces {} and separating them with commas, you pass an "array constant" to the function. This forces Excel to evaluate the criteria independently, returning an array of counts. Finally, the SUM function adds those individual counts together.
Imagine you have a list of store locations in column A, and you want to count how many stores are in "New York", "Boston", or "Chicago".
| Row | A (City) | B (Sales) |
|---|---|---|
| 1 | New York | $12,000 |
| 2 | Los Angeles | $15,000 |
| 3 | Boston | $8,000 |
| 4 | Chicago | $9,500 |
| 5 | Miami | $11,000 |
| 6 | Boston | $7,200 |
To count the rows matching "New York", "Boston", or "Chicago", use this formula:
=SUM(COUNTIF(A1:A6, {"New York", "Boston", "Chicago"}))
Evaluation steps:
COUNTIF(A1:A6, {"New York", "Boston", "Chicago"}) returns the array: {1, 2, 1} (1 New York, 2 Bostons, 1 Chicago).SUM({1, 2, 1}) adds these values up to return 4.Note: If you have your criteria listed in a range of cells (e.g., D1:D3) instead of hardcoding them, use SUMPRODUCT instead of SUM: =SUMPRODUCT(COUNTIF(A1:A6, D1:D3)).
The COUNTIF array method works beautifully for a single column. But what if your criteria span across different columns? For example, you want to count rows where the Region is "East" OR the Product is "Tablet".
For multi-column "OR" logic, SUMPRODUCT is the ultimate tool. In Boolean algebra, addition (+) represents the "OR" operator, while multiplication (*) represents the "AND" operator.
=SUMPRODUCT(--((range1="criterion1") + (range2="criterion2") > 0))
(range1="criterion1") and (range2="criterion2") produce arrays of TRUE and FALSE values.(+) acts as an OR gate. If a row matches one criterion, it yields 1 + 0 = 1. If it matches both, it yields 1 + 1 = 2. If it matches neither, it yields 0 + 0 = 0.> 0 comparison ensures that rows matching both criteria are not double-counted (transforming 2 back into TRUE, which is equivalent to 1).--) converts the resulting TRUE/FALSE values into 1s and 0s, which SUMPRODUCT then sums.Consider the following dataset:
| Row | A (Region) | B (Product) |
|---|---|---|
| 1 | East | Laptop |
| 2 | West | Tablet |
| 3 | East | Tablet |
| 4 | South | Phone |
| 5 | North | Laptop |
To count rows where Region is "East" OR Product is "Tablet":
=SUMPRODUCT(--(((A1:A5="East") + (B1:B5="Tablet")) > 0))
Evaluation breakdown:
The resulting array of {TRUE, TRUE, TRUE, FALSE, FALSE} is converted by -- to {1, 1, 1, 0, 0}, which sums to 3.
If your "OR" criteria are completely mutually exclusive-meaning a single row can never meet more than one criterion at the same time-you can simply add multiple COUNTIFS formulas together.
=COUNTIFS(range, "criterion1") + COUNTIFS(range, "criterion2")
This method is highly readable and perfect for beginners. For example, if you want to count how many employees are in either the "HR" department or the "IT" department, an employee can only belong to one department. There is zero risk of double-counting.
Example:
=COUNTIFS(C2:C100, "HR") + COUNTIFS(C2:C100, "IT")
Warning: Do not use this method across different columns where overlapping data can occur. For instance, =COUNTIFS(A2:A100, "East") + COUNTIFS(B2:B100, "Tablet") will double-count any row that is both "East" and "Tablet". Use the SUMPRODUCT method instead for such scenarios.
If you are using modern versions of Excel (Excel 365 or Excel 2021+), you have access to dynamic array functions. Combining FILTER and ROWS provides an incredibly intuitive way to perform conditional counts with "OR" logic.
=ROWS(FILTER(range, (criteria1) + (criteria2)))
The FILTER function isolates only the rows that match your criteria. Just like in the SUMPRODUCT method, the + symbol acts as the "OR" operator. Once the filtered list of rows is returned, the ROWS function simply counts how many rows are in that filtered array.
Using the same dataset from Method 2, if you want to count rows where Region is "East" OR Product is "Tablet":
=ROWS(FILTER(A1:B5, (A1:A5="East") + (B1:B5="Tablet")))
Why this is great: It is visually straightforward and matches how we think about filtering data manually. If no rows match the criteria, FILTER will return a #CALC! error. To prevent this, wrap the formula in IFERROR:
=IFERROR(ROWS(FILTER(A1:B5, (A1:A5="East") + (B1:B5="Tablet"))), 0)
To help you choose the best formula for your spreadsheet, consult the quick-reference table below:
| Scenario | Best Formula Method | Excel Version Compatibility |
|---|---|---|
| Single Column, multiple OR criteria (e.g., Red OR Blue OR Green) | SUM(COUNTIF(range, {"crit1", "crit2"})) |
All Excel versions |
| Multiple Columns with overlapping OR criteria | SUMPRODUCT(--((cond1)+(cond2)>0)) |
All Excel versions |
| Mutually Exclusive criteria (no risk of double-counting) | COUNTIFS(r, c1) + COUNTIFS(r, c2) |
All Excel versions |
| Dynamic, intuitive lists and modern calculations | ROWS(FILTER(array, (cond1)+(cond2))) |
Excel 365 / 2021+ |
By mastering these four techniques, you can tackle any complex counting requirement in Excel without relying on messy helper columns or VBA code. Try them out in your next spreadsheet and enjoy cleaner, more efficient data analysis!
Disclaimer:
The documents and templates provided on this page are for informational and illustrative purposes only. They do not constitute professional, legal, or financial advice, and should not be relied upon as such. Because individual circumstances and regulatory requirements vary, these materials may not be suitable for your specific needs. We recommend consulting with a qualified professional before adapting or using any of these examples for official or commercial purposes.