Pregunta

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.

¿Fue útil?

Solución 3

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

Otros consejos

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,"=?*")

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.

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

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top