Formula Errors

How to Count Unique Filtered Results as Zero in Excel

Emma BrownEmma Brown Nov 3, 2026 870 views

Question details

The user needs to count the number of unique items returned by a FILTER function, ensuring the result is exactly 0 instead of 1 when there are no matches.

How to Count Unique Filtered Results as Zero in Excel
Product
Excel
Device & OS
not provided
Scenario
Counting unique occurrences based on specific conditions using the UNIQUE and FILTER functions, particularly when encountering empty result sets.
Observed behavior
When the FILTER function finds no matches, the nested COUNTA function counts the resulting empty string as 1 instead of 0, creating an inaccurate count.
Before you start

Ensure your version of Excel or WPS Spreadsheet supports dynamic array functions like UNIQUE and FILTER before applying these formulas.

Solution 1Recommended

Use SUMPRODUCT to Count Only Non-Blank Results

Replace the COUNTA function with a SUMPRODUCT formula to check if the returned values are not blank before executing the count.

When a FILTER function returns no matches, it typically outputs an empty string based on your fallback argument. A standard COUNTA function considers this empty string as a valid cell entry and counts it as 1. By wrapping the array in SUMPRODUCT and explicitly checking for non-blank values, you resolve this logic error.

1
Select the destination cell

Click on the cell where you want the final count to be displayed.

2
Input the SUMPRODUCT formula

Enter the formula: =SUMPRODUCT(1*(UNIQUE(FILTER($A$2:$A$6,($B$2:$B$6=F$1)*($C$2:$C$6=2021),""))<>"")) into the formula bar.

3
Apply the calculation

Press Enter. The formula will now accurately return 0 when the FILTER function finds no matching criteria, and will correctly count non-blank unique results otherwise.

Use SUMPRODUCT to Count Only Non-Blank Results
Why this formula works: SUMPRODUCT multiplies the boolean array (TRUE/FALSE results from checking against blank strings) by 1, converting them to 1s and 0s. It then sums them up, completely ignoring the empty strings.
Master Advanced Formulas with WPS Office

Use Advanced Array Formulas Seamlessly in WPS Spreadsheet

WPS Spreadsheet fully supports dynamic array formulas, including UNIQUE, FILTER, and SUMPRODUCT, making it easy to filter and count your data accurately.

  1. 1. Open your file: Launch WPS Spreadsheet and open the dataset you are working on.
  2. 2. Select the target cell: Click on the cell where you need the unique count calculation.
  3. 3. Enter the formula: Type the nested SUMPRODUCT, UNIQUE, and FILTER formula.
  4. 4. View the accurate count: Press Enter to execute. The cell will seamlessly calculate your data, displaying a true zero when no matches are found.
Fully compatible with Microsoft Excel formulas and .xlsx formats.Supports modern dynamic array functions out of the box.Free and lightweight alternative for complex data analysis.
microsoft office alternative - wps office

Frequently Asked Questions

Why does COUNTA return 1 instead of 0 for empty formula results?

COUNTA counts any cell that is not technically empty. If a formula like FILTER returns an empty text string ("") or an error value, COUNTA considers that cell to contain data and therefore counts it as 1.

Can I use the COUNT function instead of COUNTA to fix this?

No, the COUNT function only counts numeric values. If your UNIQUE and FILTER formula returns text strings (such as names, categories, or regions), COUNT will ignore them and always return zero, regardless of how many matches exist.

Are UNIQUE and FILTER functions available in all spreadsheet software?

Dynamic array functions like UNIQUE and FILTER are only available in modern spreadsheet applications, such as Microsoft 365, Excel 2021, and WPS Office. In older versions, using these functions will return a #NAME? error.