### How do I do COUNTIF() or COUNTIFS()?

`COUNTIF(col, expr)`

, where `col`

is a **whole-column** reference (e.g., `A`

), is similar to:

```
COUNT(
FILTER(
"table",
([col] expr)
)
)
```

`COUNTIFS(col1, expr1, col2, expr2, ...)`

, where `col1`

and `col2`

are each **whole-column** references, is similar to:

```
COUNT(
FILTER(
"table",
AND(
([col1] expr1),
([col2] expr2),
...
)
)
)
```

To limit the rows included in the *COUNT()* range (e.g., as with `COUNTIF(A3:A7, ...)`

), include the limit criteria in the *FILTER()* sub-expression, similar to this:

```
COUNT(
FILTER(
"table",
AND(
([_ROWNUMBER] >= low-row-num),
([_ROWNUMBER] <= hi-row-num),
([col] expr)
)
)
)
```

To count across multiple columns (e.g., as with `COUNTIF(A:C, ...)`

), you may add the results of an additional *FILTER()* sub-expression for each additional column:

```
COUNT(
FILTER(...)
+ FILTER(...),
...
)
```

See also: *AND()*, *COUNT()*