How to Make COUNTA, UNIQUE, and FILTER Return Zero for Blank Results in Excel
Question details
The user needs a combined COUNTA, UNIQUE, and FILTER formula to return exactly 0 or remain blank when there are no qualifying matching results in the dataset.

- Product
- Excel
- Device & OS
- not provided
- Scenario
- Filtering a dataset for unique values based on multiple conditions and counting the results, especially in cases where no matching data exists.
- Observed behavior
- The formula returns 1 when no qualifying data exists because COUNTA interprets the empty string returned by the FILTER function as a valid text value.
Verify that your version of Excel or spreadsheet software supports dynamic array functions like UNIQUE and FILTER, and double-check your data range references for any typos.
Use IF and COUNTIFS to Test for Matching Rows First
Prevent the COUNTA function from executing by verifying if any data matches your criteria first using COUNTIFS.
This method involves pre-checking your conditions. If no rows meet your criteria, the IF function immediately outputs 0, bypassing the COUNTA and FILTER operations entirely and avoiding the erroneous '1' result.
Click on the cell where you want to output the counted unique values.
Modify your existing formula by nesting it inside an IF statement that checks your criteria using COUNTIFS first.
Input the following formula: =IF(COUNTIFS('BP Data'!D:D,A3,'BP Data'!G:G,">0")=0, 0, COUNTA(UNIQUE(FILTER('BP Data'!M:M,('BP Data'!D:D=A3)*('BP Data'!G:G>0),""))))
Press Enter to apply. The cell will now accurately display 0 when there are no qualifying matches.

Omit FILTER's Third Argument and Use IFERROR
Force the FILTER function to trigger an error when no results are found, and catch it using IFERROR.
Utilize TOCOL Function to Ignore Blanks
Use the TOCOL function to actively strip out empty values before COUNTA analyzes the array.
Master Advanced Formulas with WPS Office
WPS Spreadsheet fully supports modern dynamic array functions like FILTER, UNIQUE, and TOCOL, making it effortless to analyze complex data without error messages. Its seamless interface and robust calculation engine ensure your formulas work exactly as intended.
- 1. Open your dataset: Launch WPS Spreadsheet and open the document containing your data.
- 2. Select the output cell: Click on the cell where you want to calculate your unique counts.
- 3. Enter the refined formula: Type your IFERROR or IF-COUNTIFS formula exactly as you would in standard spreadsheet applications.
- 4. Calculate instantly: Press Enter. WPS Spreadsheet handles the dynamic array and instantly outputs the accurate count without erroneous '1' results.

Frequently Asked Questions
Why does COUNTA return 1 for a blank FILTER result?
When the FILTER function has no matches and returns an empty text string ("") as instructed by its 'if_empty' argument, COUNTA sees this empty string as a valid non-blank value, thereby returning a count of 1.
What happens if I don't provide a third argument to the FILTER function?
If no matching data is found and the third argument is omitted, the FILTER function returns a #CALC! error. Wrapping your formula in IFERROR can catch this error and turn it into a 0.
Are UNIQUE and FILTER functions available in all spreadsheet versions?
No, dynamic array functions like UNIQUE, FILTER, and TOCOL are available in newer spreadsheet software like modern WPS Office Spreadsheet, Microsoft 365, and Excel 2021 or later. Older versions do not support them natively.




