'Countif with len in Google Spreadsheet

I have a column XXX like this :

XXX


A
Aruin
Avolyn
B
Batracia
Buna
...

I would like to count a cell only if the string in the cell has a length > 1. How to do that? I'm trying :

COUNTIF(XXX1:XXX30, LEN(...) > 1)

But what should I write instead of ... ?

Thank you in advance.



Solution 1:[1]

Create another list using an =ARRAYFORMULA(len(XXX1:XXX30)>1) and then do a COUNTIF based on that new list: =countif(XXY1:XXY30,true()).

Solution 2:[2]

For ranges that contain strings, I have used a formula like below, which counts any value that starts with one character (the ?) followed by 0 or more characters (the *). I haven't tested on ranges that contain numbers.

=COUNTIF(range,"=?*")

Solution 3:[3]

To do this in one cell, without needing to create a separate column or use arrayformula{}, you can use sumproduct.

=SUMPRODUCT(LEN(XXX1:XXX30)>1)

If you have an array of True/False values then you can use -- to force them to be converted to numeric values like this:

=SUMPRODUCT(--(LEN(XXX1:XXX30)>1))

Credit to @greg who posted this in the comments - I think it is arguably the best answer and should be displayed as such. Sumproduct is a powerful function that can often to be used to get around shortcomings in countif type formulae.

Solution 4:[4]

A simple formula that works for my needs is =ROWS(FILTER(range,LEN(range)>X))

The Google Sheets criteria syntax seems inconsistent, because the expression that works fine with FILTER() gives an erroneous zero result with COUNTIF().

Here's a demo worksheet

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 mdega
Solution 2 xolotl
Solution 3 Cassiopeia
Solution 4 David Knapp