WorkbookLogic
FormulaFreeAggregationintermediateCOUNTIFSSUMPRODUCTIFANDSUM

Count Rows Where Two Criteria Match

By WorkbookLogic

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.

ExcelLast reviewed Sep 11, 2026
count-if-two-criteria-match-v1.0.0.xlsxFree
Count If Two Criteria Match, Formula Review
Compare single-condition counts, COUNTIFS with AND logic, and the SUMPRODUCT equivalent.
Source data, syntheticCOUNTIFS and SUMPRODUCT review, editable criteria
OrderColorQuantityColor criterionBlue
ORD-001Red10Quantity threshold15
ORD-002Blue12
ORD-003Green22ExampleFormula syntaxResult
ORD-004Blue18Color only=COUNTIFS($B$12:$B$22,$F$11)5
ORD-005Red20Quantity only=COUNTIFS($C$12:$C$22,">"&$F$12)6
ORD-006Blue25Both criteria=COUNTIFS($B$12:$B$22,$F$11,$C$12:$C$22,">"&$F$12)3
ORD-007Green15SUMPRODUCT equivalent=SUMPRODUCT(($B$12:$B$22=$F$11)*($C$12:$C$22>$F$12))3
ORD-008Red8
ORD-009Blue30
ORD-010Green19
ORD-011Blue14
Reliability checks
COUNTIFS returns the expected three matching rowsOK
COUNTIFS reconciles to the SUMPRODUCT equivalentOK

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

Combined Example!G11

Blue

Quantity threshold

Combined Example!G12

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

  1. Compare every Color with the selected text criterion.
  2. Join the > operator to the editable numeric threshold.
  3. Compare every aligned Quantity with that constructed criterion.
  4. Count a row only when both tests are true.
  5. 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.