Count Rows Where Two Criteria Match
Count records only when a text condition and numeric threshold both match the same row, with aligned COUNTIFS ranges and an independent SUMPRODUCT reconciliation for verification.
| Count If Two Criteria Match, Formula Review | ||||||
| Compare single-condition counts, COUNTIFS with AND logic, and the SUMPRODUCT equivalent. | ||||||
| Source data, synthetic | COUNTIFS and SUMPRODUCT review, editable criteria | |||||
| Order | Color | Quantity | Color criterion | Blue | ||
| ORD-001 | Red | 10 | Quantity threshold | 15 | ||
| ORD-002 | Blue | 12 | ||||
| ORD-003 | Green | 22 | Example | Formula syntax | Result | |
| ORD-004 | Blue | 18 | Color only | =COUNTIFS($B$12:$B$22,$F$11) | 5 | |
| ORD-005 | Red | 20 | Quantity only | =COUNTIFS($C$12:$C$22,">"&$F$12) | 6 | |
| ORD-006 | Blue | 25 | Both criteria | =COUNTIFS($B$12:$B$22,$F$11,$C$12:$C$22,">"&$F$12) | 3 | |
| ORD-007 | Green | 15 | SUMPRODUCT equivalent | =SUMPRODUCT(($B$12:$B$22=$F$11)*($C$12:$C$22>$F$12)) | 3 | |
| ORD-008 | Red | 8 | ||||
| ORD-009 | Blue | 30 | ||||
| ORD-010 | Green | 19 | ||||
| ORD-011 | Blue | 14 | ||||
| Reliability checks | ||||||
| COUNTIFS returns the expected three matching rows | OK | |||||
| COUNTIFS reconciles to the SUMPRODUCT equivalent | OK | |||||
Overview
Return one count of rows where two conditions are true together. The example counts orders whose Color is Blue and whose Quantity is strictly greater than 15, then reconciles COUNTIFS to a Boolean SUMPRODUCT calculation and visible row flags.
When to use it
Use it for counts by department and status, product and quantity threshold, customer class and ageing band, or pipeline stage and value threshold. Each source record must occupy one row and every criteria range must share the same boundaries.
When not to use it
Use SUMPRODUCT when criteria require array transformations that COUNTIFS cannot express directly. Use a PivotTable for an interactive matrix of many category combinations. Use COUNTIF when only one condition is required.
Problem
Adding two separate counts does not identify their intersection: a row may satisfy one condition but not the other. The calculation must test both fields on the same row and must build comparison operators correctly when the threshold sits in an editable cell.
Inputs
Input | Location | Sample |
|---|---|---|
Color criterion | | Blue |
Quantity threshold | | 15 |
Source data
The synthetic source in A12:C22 contains one order per row. The Blue records are:
Order | Color | Quantity |
|---|---|---|
ORD-002 | Blue | 12 |
ORD-004 | Blue | 18 |
ORD-006 | Blue | 25 |
ORD-009 | Blue | 30 |
ORD-011 | Blue | 14 |
Color is text and Quantity is numeric. Duplicate colors are expected; duplicate order identifiers do not change the count. Sorting does not matter if aligned columns remain together. Blank quantities do not exceed a positive threshold.
Calculations
- Compare every Color with the selected text criterion.
- Join the
>operator to the editable numeric threshold. - Compare every aligned Quantity with that constructed criterion.
- Count a row only when both tests are true.
- Recalculate the same Boolean intersection with SUMPRODUCT.
Outputs
The formula returns 3. Five rows are Blue, but only quantities 18, 25, and 30 are strictly greater than 15. A result of zero means no row satisfies both conditions; it is not an error.
Formula map
=COUNTIFS($B$12:$B$22,$G$11,$C$12:$C$22,">"&$G$12)
The two range and criteria pairs implement AND logic. ">"&$G$12 constructs the criterion >15. Absolute references keep the source and selections fixed; the formula returns one count and does not spill.
Model checks
The workbook confirms that COUNTIFS returns the expected three rows and equals the SUMPRODUCT equivalent. A row-level flag column also sums to three, exposing which records contribute. Passing checks return OK.
Edge cases
- A quantity equal to 15 is excluded because the operator is strictly greater than.
- Text comparisons are not case-sensitive.
- Wildcards
*and?have special meaning in criteria and require escaping for literal matching. - Blank quantities do not satisfy this positive threshold.
- Criteria ranges with different dimensions return an error or invalidate alignment.
Common errors
- Omitting concatenation: using only the threshold reference loses the
>rule. Build it as">"&G12. - Adding component counts: this measures two populations rather than their intersection. Put both pairs inside one COUNTIFS.
- Using different range boundaries: records no longer align. Lock every criteria range to the same rows.
Example
Among the five Blue orders, quantities are 12, 18, 25, 30, and 14. Only 18, 25, and 30 exceed 15, so the result is 3. The independent Boolean sum 0 + 1 + 1 + 1 + 0 also equals 3.
Example workbook
Replace the cream criteria in Combined Example!G11:G12 or edit the source in A12:C22. The result, row flags, and checks sit alongside the source. Formula Review compares the Color-only, Quantity-only, combined COUNTIFS, and SUMPRODUCT results.
Key takeaway
Put aligned range and criteria pairs inside one COUNTIFS so every condition is evaluated on the same row, and concatenate operators to editable thresholds explicitly.