Practice problems / Lookup & Reference

Flag a double-booked order (COUNTIF)

Easy Lookup & Reference
Description
Hints 0/4
Solutions 2
–
Test case
1
2
3
Reset
Submit
fx
A
B
C
D
E
F
G
1
2
3
4
5
6
7
8
9
10
Loading interactive spreadsheet...
Preparing grid cells and formula calculation engine
○ Ready Enter formula in highlighted cells, then click Submit.

The problem

Problem statement

A customer swears they were charged twice, and the order log looks suspicious: order ID ORD-1042 might have been booked more than once. Before refunding anything, count how many rows in A2:A11 carry that exact ID. The disputed ID is already sitting in D1. Put the answer in the D2 cell D2.

The criteria is text: quote the order ID (or point at the cell holding it) — case 3 appears once, so 1 is correct.

Problem data

Show the sheet as a table (selectable, copyable)
The exercise data, as a table
ABD
1 Order IDAmountORD-1042
2 ORD-1037120
3 ORD-1042250
4 ORD-105189
5 ORD-1042250
6 ORD-1063340
7 ORD-1078150
8 ORD-109099
9 ORD-1104210
10 ORD-1119175
11 ORD-112560

Notes

COUNTIF's second argument is the criteria. Text criteria needs quotes: "ORD-1042". The match is exact (but not case-sensitive): "ord-1042" works too. This is the same engine behind conditional formatting's Duplicate Values rule and Sheets' custom formula =COUNTIF($A$2:$A$11,A2)>1 — count first, then act.

How to approach

Your answer goes in D2. On submit we re-run your formula against 3 different sets of input, so a hardcoded number will fail — the formula has to follow the cells.

  1. Target cell is D2
  2. The range to count over is A2:A11
  3. The criteria is the order ID as text — quote it, or point at the cell that holds it
  4. Shape: =COUNTIF(?, ?) — range first, then the criteria

Official solutions

Show 2 solutions — try it yourself first

Approach 1: COUNTIF with the order ID as text criteria

=COUNTIF(A2:A11, "ORD-1042")

COUNTIF walks A2:A11 and counts every cell equal to "ORD-1042". Two matches means the order really was booked twice — time to escalate before refunding.

Approach 2: point the criteria at a label cell

=COUNTIF(A2:A11, D1)

D1 already holds the order ID, so the criteria can reference it directly. When tomorrow's complaint is about ORD-1051, just change D1 — the formula never needs editing.

Function guide

Related practice

FAQ

How do I find duplicates in Excel with COUNTIF?

Add a helper column with =COUNTIF($A$2:$A$11,A2) and fill down — any value greater than 1 is a duplicate. Filter or conditional-format on that column to see them all at once.

How do I highlight duplicates in Google Sheets?

Select the range, then Format → Conditional formatting. Under Format rules choose Custom formula is and enter =COUNTIF($A$2:$A$11,A2)>1, then pick a fill color.

Is COUNTIF case-sensitive?

No. "ORD-1042" and "ord-1042" both match. If you ever need a case-sensitive count, use SUMPRODUCT with EXACT: =SUMPRODUCT(--EXACT(A2:A11,"ORD-1042")).