Function Problems

Why COUNTIF Fails with LET and Calculated Arrays in Excel & How to Fix It

Khadija KhanKhadija Khan Nov 11, 2026 869 views

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.

Why COUNTIF Fails with LET and Calculated Arrays in Excel
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.
Before you start

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.

Solution 1Recommended

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.

1
Set up your LET or FILTER array

Define your array within your formula, for example: LET(myArray, FILTER(A2:A100, B2:B100>50), ...)

2
Apply the condition using boolean logic

Instead of trying to write COUNTIF(myArray, ">10"), write (myArray>10) to generate an array of TRUE/FALSE values.

3
Wrap with SUM and double negation

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)).

Use SUM or SUMPRODUCT as an Alternative to COUNTIF
Performance Benefit: Using SUMPRODUCT or SUM with boolean logic is universally supported across modern spreadsheet tools and processes in-memory arrays without needing helper columns.

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. 1. Open WPS Spreadsheet: Launch WPS Office and open your workbook containing the data.
  2. 2. Select the target cell: Click on the cell where you want the final count to appear.
  3. 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. 4. Calculate the result: Press Enter to calculate the dynamic array and return the exact count instantly.
Full support for advanced formulas including LET, FILTER, and SUMPRODUCT.Seamless compatibility with Microsoft Excel (.xlsx) formats.Free, lightweight, and fast performance for heavy data sets.Intuitive interface for formula auditing and error checking.
microsoft office alternative - wps office

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.