Why COUNTIF Fails with LET and Calculated Arrays in Excel & How to Fix It
Question details
The user is trying to use the COUNTIF or COUNTIFS function to count items within a dynamic array generated by functions like LET or FILTER, but the formula returns an error instead of the expected count.

- Product
- Excel / WPS Spreadsheet
- Device & OS
- not provided
- Scenario
- Writing advanced formulas combining COUNTIF with dynamic arrays generated in memory by functions like LET or FILTER.
- Observed behavior
- The formula returns a #VALUE! error because COUNTIF expects a physical worksheet cell range, rather than an in-memory calculated array.
Ensure you have a basic understanding of dynamic array functions and check if your spreadsheet software supports functions like LET, FILTER, MAP, or SUMPRODUCT before applying these workarounds.
Use SUM or SUMPRODUCT as an Alternative to COUNTIF
Since COUNTIF doesn't accept calculated arrays, you can evaluate the condition directly against the array and sum the TRUE values.
Functions like COUNTIF and SUMIF require physical cell ranges (like A1:A10). When you pass a dynamically calculated array from LET or FILTER, it exists only in memory, causing an error. Using SUM with double negation (--) converts boolean TRUE/FALSE results into 1s and 0s, allowing you to count them effectively.
Define your array within your formula, for example: LET(myArray, FILTER(A2:A100, B2:B100>50), ...)
Instead of trying to write COUNTIF(myArray, ">10"), write (myArray>10) to generate an array of TRUE/FALSE values.
Complete the formula by wrapping it in SUM and converting the booleans into numeric values: SUM(--(myArray>10)). Alternatively, you can use SUMPRODUCT(--(myArray>10)).

Spill the Array to a Physical Range First
Output the results of your LET or FILTER function to a blank column, then point your COUNTIF function to that physical range.
Utilize MAP or BYROW for Complex Array Counting
For more complex row-by-row or element-by-element evaluations, Lambda helper functions can iterate over the calculated array to generate counts.
Handle Dynamic Arrays Efficiently in WPS Spreadsheet
WPS Spreadsheet fully supports advanced dynamic array functions like LET, FILTER, and Lambda combinations. You can seamlessly apply the SUM and boolean logic workarounds to count filtered data without compatibility issues.
- 1. Open WPS Spreadsheet: Launch WPS Office and open your workbook containing the data.
- 2. Select the target cell: Click on the cell where you want the final count to appear.
- 3. Enter the SUM workaround formula: Type your array formula using the SUM boolean method, for example: =SUM(--(FILTER(A1:A10, B1:B10="Criteria")>5))
- 4. Calculate the result: Press Enter to calculate the dynamic array and return the exact count instantly.

Frequently Asked Questions
Why does COUNTIF require a physical range?
Functions like COUNTIF, SUMIF, and AVERAGEIF were designed in early spreadsheet engines to work strictly with physical cell references to optimize processing performance. They lack the internal architecture to parse dynamic, in-memory arrays generated by newer functions like LET and FILTER.
Does SUMPRODUCT work with calculated arrays?
Yes. Unlike COUNTIF, SUMPRODUCT is designed to natively handle and evaluate arrays. You can use it to count array conditions safely, such as =SUMPRODUCT(--(myArray="value")).
Can I use the spill operator (#) with COUNTIF?
Yes. If you output a dynamic array directly onto the grid (for example, starting in cell C1), you can use =COUNTIF(C1#, "criteria") because the spilled data occupies actual physical cells that COUNTIF can read.
What is the LET function used for?
The LET function allows you to assign names to calculation results or values within a formula. It improves formula readability and boosts performance by preventing the spreadsheet from calculating the same expression multiple times.




