Excel COUNTIF & COUNTIFS Complete Guide: Wildcards, Multiple Criteria, Date Ranges, Duplicate Counts, and Unique Counts

Excel COUNTIF & COUNTIFS: wildcards, multiple criteria, date ranges, and unique counts, with a realistic Kkong-i pointing at a laptop thumbnail
Excel COUNTIF & COUNTIFS Complete Guide: Wildcards, Multiple Criteria, Date Ranges, Duplicate Counts, and Unique Counts

Excel COUNTIF & COUNTIFS Complete Guide: Wildcards, Multiple Criteria, Date Ranges, Duplicate Counts, and Unique Counts

Environment: Based on Excel 365. AI tools were used as an aid in organizing the draft, but all formulas were personally reproduced and verified.

1) Cheat Sheet (Basic Syntax)

// COUNTIF(range, criteria)
=COUNTIF(A2:A100, "*blue*")      // contains 'blue'

// COUNTIFS(range1, criteria1, range2, criteria2, ...)
=COUNTIFS(Category,"=Fruit", Region,"Seoul", Qty, ">=10")

TIP Enter comparison operators (such as >=) as text, and use & to concatenate them with a cell reference, as in ">="&B1.

2) 8 Wildcard (Partial-Match) Examples

=COUNTIF(A2:A,"*서울*")                // contains 'Seoul'
=COUNTIF(A2:A,"서울*")                 // starts with 'Seoul'
=COUNTIF(A2:A,"*구")                   // ends with 'gu'
=COUNTIF(A2:A,"A?C")                   // A_ C (one character)
=COUNTIF(A2:A,"*~**")                  // literal asterisk (escape: ~)
=COUNTIF(A2:A,"*?*?*")                 // length ≥2
=COUNTIF(A2:A,"<>")                   // number of nonblank cells
=COUNTIF(A2:A,"<>*취소*")            // does not contain 'canceled'

3) 10 COUNTIFS Multiple-Criteria Examples (Ready to Copy and Paste)

// ① Category=Fruit & Region=Seoul
=COUNTIFS(Tbl[Category],"Fruit", Tbl[Region],"Seoul")

// ② Amount from 100,000 to 500,000
=COUNTIFS(Tbl[Amount], ">="&100000, Tbl[Amount], "<="&500000)

// ③ Text contains + quantity condition
=COUNTIFS(Tbl[Item], "*사과*", Tbl[Qty], ">="&10)

// ④ Specific month (2025-08)
=COUNTIFS(Tbl[Date], ">="&DATE(2025,8,1), Tbl[Date], "<"&DATE(2025,9,1))

// ⑤ Blank/nonblank
=COUNTIFS(Tbl[Phone], "")              // blank cells
=COUNTIFS(Tbl[Phone], "<>")         // contains a value

// ⑥ When case sensitivity is required (with FIND)
=SUMPRODUCT(--ISNUMBER(FIND("ABC", Tbl[Code])))

// ⑦ Exclude Saturday and Sunday (weekdays only)
=COUNTIFS(Tbl[Date], ">="&B1, Tbl[Date], "<="&C1, Tbl[Date], "<>","", WEEKDAY(Tbl[Date],2), "<=5")

// ⑧ Exclude errors
=COUNTIFS(Tbl[Result], "<>#N/A")

// ⑨ Contains at least one of several keywords (OR)
=SUM(COUNTIF(Tbl[Item], {"*사과*","*배*","*포도*"}))

// ⑩ Combined AND + OR
=SUM(COUNTIFS(Tbl[Region],"Seoul", Tbl[Item], {"*사과*","*배*"}))

4) 6 Date and Time Range Examples

// ① Today
=COUNTIFS(Tbl[Date], TODAY())

// ② Last 7 days
=COUNTIFS(Tbl[Date], ">="&TODAY()-7, Tbl[Date], "<="&TODAY())

// ③ By month (same month as the cell)
=COUNTIFS(Tbl[Date], ">="&EOMONTH(B1,-1)+1, Tbl[Date], "<="&EOMONTH(B1,0))

// ④ Time range (09:00–18:00)
=COUNTIFS(Tbl[Time], ">="&TIME(9,0,0), Tbl[Time], "<="&TIME(18,0,0))

// ⑤ Weekends only
=COUNTIFS(WEEKDAY(Tbl[Date],2),">=6")

// ⑥ Quarter (Q3)
=COUNTIFS(Tbl[Date], ">="&DATE(2025,7,1), Tbl[Date], "<"&DATE(2025,10,1))

5) 4 Duplicate and Unique Count Examples

// ① Count table by value (without a PivotTable)
=LET(u, UNIQUE(Tbl[Item]), HSTACK(u, BYROW(u, LAMBDA(x, COUNTIF(Tbl[Item], x)))))

// ② Number of values that appear at least twice
=COUNTIF(COUNTIF(Tbl[Item], Tbl[Item]), ">=2")

// ③ Number of unique values
=ROWS(UNIQUE(Tbl[Item]))

// ④ Conditional unique count (Region=Seoul)
=ROWS(UNIQUE(FILTER(Tbl[Item], Tbl[Region]="Seoul")))

6) Error and Performance Checklist

  • Mixed numbers and text → normalize with --value or VALUE()
  • Text dates → convert with DATEVALUE
  • Large data sets → use a table (Table) and minimize column ranges; preprocess with Power Query when needed
  • To find literal wildcard characters → escape them with ~* and ~?
  • Provide user-friendly messages with IFERROR: =IFERROR(formula,"None")

Leave a Reply

Your email address will not be published. Required fields are marked *