Function Problems

How to Count Unique Excel Values Containing a Specific Character

Khadija KhanKhadija Khan Nov 11, 2026 868 views

Question details

The user needs to count distinct (unique) values in a data range that contain a specific letter or character, including options for both case-sensitive and case-insensitive matching.

How to Count Unique Excel Values Containing a Specific Character
Product
Excel
Device & OS
not provided
Scenario
Data analysis requiring the extraction of unique items that meet a specific text criteria.
Observed behavior
The goal is to accurately calculate the total number of unique matching values without double-counting duplicates.
Before you start

Ensure you are using a modern version of Excel or WPS Spreadsheet that supports dynamic array formulas, specifically the UNIQUE function.

Solution 1Recommended

Use Dynamic Array Formulas with UNIQUE and SEARCH (Recommended)

Combine SUM, ISNUMBER, SEARCH (or FIND), and UNIQUE to cleanly count specific values without creating extra helper columns.

This method uses dynamic array functions to first filter out duplicates, and then validates whether the remaining unique strings contain the target character.

1
Select a blank cell

Click on an empty cell in your worksheet where you want the final count to be displayed.

2
Enter the case-insensitive formula

For a case-insensitive count (matches both 'P' and 'p'), type the formula: =SUM(--ISNUMBER(SEARCH("p",UNIQUE(A2:A18)))) and press Enter.

3
Enter the case-sensitive formula

If you need an exact case match, use FIND instead of SEARCH: =SUM(--ISNUMBER(FIND("P",UNIQUE(A2:A18)))).

4
Count values excluding the character

To count unique values that do not contain the target letter, swap ISNUMBER with ISERROR: =SUM(--ISERROR(SEARCH("p",UNIQUE(A2:A18)))).

Use Dynamic Array Formulas with UNIQUE and SEARCH (Recommended)
Formula Breakdown: The UNIQUE function filters duplicates first. SEARCH/FIND checks for the character, ISNUMBER turns matches into TRUE/FALSE, and the double negative (--) converts them into 1s and 0s for SUM to calculate.
Process Data Faster

Count Unique Data Efficiently with WPS Spreadsheet

WPS Spreadsheet fully supports dynamic array functions like UNIQUE and FILTER, allowing you to seamlessly analyze text criteria and count specific characters. Enjoy a familiar interface and strong compatibility with Microsoft Excel.

  1. 1. Open your data file: Launch WPS Spreadsheet and open the workbook containing your target data column.
  2. 2. Apply the array formula: Click on a blank cell and type =SUM(--ISNUMBER(SEARCH("P", UNIQUE(A2:A18)))).
  3. 3. Calculate the result: Press Enter to instantly process the array and return the exact unique character count.
Fully compatible with Microsoft Excel formulas and file formats (.xlsx)Native support for dynamic array functions like UNIQUE, FILTER, and SEARCHLightweight, fast, and completely free to useBuilt-in tools to assist with complex formula writing
microsoft office alternative - wps office

Frequently Asked Questions

Why does my UNIQUE formula return a #NAME? error?

This error occurs if you are using an older version of Excel that doesn't support the UNIQUE dynamic array function. You will need Microsoft 365, Excel 2021, or a modern alternative like WPS Spreadsheet to use this formula.

What is the difference between SEARCH and FIND in these formulas?

The SEARCH function is case-insensitive, meaning it treats 'P' and 'p' as the same character. The FIND function is case-sensitive and will only match the exact uppercase or lowercase character you specify.

How can I count unique values that exactly match a specific word instead of just containing a character?

You can use the formula =COUNTA(UNIQUE(FILTER(A2:A18, A2:A18="ExactWord"))). The FILTER function handles the exact match condition before UNIQUE removes duplicates and COUNTA calculates the total.