Function Problems

How to Count Distinct Partial Matches in Excel (COUNTIF & UNIQUE)

Bushra ParveenBushra Parveen Oct 28, 2026 871 views

Question details

The user needs to count the number of unique items within a range that contain a specific partial text string.

How to Count Distinct Partial Matches in Excel
Product
Excel
Device & OS
not provided
Scenario
Analyzing a dataset to find the exact number of distinct varieties (e.g., unique product names) that include a specific search keyword, ignoring duplicates.
Observed behavior
The standard COUNTIF function counts every single row that matches the criteria, meaning duplicate values containing the search term are counted multiple times instead of just once.
Before you start

Check your Excel version before proceeding, as modern dynamic array formulas (like UNIQUE and FILTER) are only available in Microsoft 365, Excel 2021, and updated versions of WPS Office.

Solution 1Recommended

Use Dynamic Array Formulas (Excel 365 & Modern Office)

The most efficient and direct method using modern array functions to filter, extract unique values, and count them in one step.

This approach nests several powerful functions. SEARCH looks for the partial text, ISNUMBER converts matches to TRUE/FALSE, FILTER isolates the matching rows, UNIQUE removes duplicates, and COUNTA counts the remaining distinct items.

1
Select a result cell

Click on the cell where you want the distinct count to appear.

2
Input the dynamic formula

Type `=COUNTA(UNIQUE(FILTER(C2:C20,ISNUMBER(SEARCH(I2,C2:C20)))))`, assuming C2:C20 is your data range and I2 contains your search term (e.g., "bean").

3
Calculate the result

Press Enter. The formula will automatically process the array and return the exact number of distinct partial matches.

Use Dynamic Array Formulas (Excel 365 & Modern Office)
Case-Insensitive Searching: The SEARCH function used in this formula is case-insensitive. If you need a case-sensitive match, replace SEARCH with the FIND function.

Count Distinct Data Effortlessly in WPS Spreadsheet

WPS Office provides robust native support for modern data analysis functions, including dynamic arrays like UNIQUE and FILTER, allowing you to solve complex counting problems without complicated workarounds.

  1. 1. Open your data file: Launch WPS Spreadsheet and open your existing .xlsx workbook.
  2. 2. Select the target cell: Click on the cell where you want to display the distinct count.
  3. 3. Enter the formula: Type the standard dynamic formula `=COUNTA(UNIQUE(FILTER(C2:C20,ISNUMBER(SEARCH(I2,C2:C20)))))`.
  4. 4. Get instant results: Press Enter to instantly calculate the unique instances of your partial text match.
Natively supports advanced array functions like UNIQUE, FILTER, and ISNUMBER.Fully compatible with Microsoft Excel (.xlsx) formats and standard formula syntax.Provides a lightweight, user-friendly interface for managing large datasets.Completely free to download and use for your daily spreadsheet tasks.
microsoft office alternative - wps office

Frequently Asked Questions

Why does the standard COUNTIF function count duplicates?

The COUNTIF function evaluates each cell in a range individually against the provided criteria. It does not possess a built-in mechanism to check if a matching value has already been counted previously in the range, which is why duplicates are included in the final tally.

How do wildcards work in partial match formulas?

Wildcards, represented by asterisks (*), stand for any number of characters. In formulas like `=COUNTIF(D2:D11,"*"&I2&"*")`, placing an asterisk before and after the cell reference tells the program to count cells where the text in I2 appears anywhere within the cell, regardless of what comes before or after it.

What happens if there are empty cells in my data range?

Empty cells can sometimes cause array functions like UNIQUE to return a '0' or an empty string, which COUNTA might accidentally count as a value (resulting in an inflated count). It is highly recommended to ensure your range is exact, or add an extra condition to your FILTER formula (e.g., `C2:C20<>""`) to exclude blanks entirely.