0
votes

I need a function in Google Sheets similar to SUMIF which counts non numeric values (text), which separates criteria from counted range.

In column 2 below, I need to count all words with their respective activity ID (column 1).

So something like COUNTIF($A2:$A, 1, $B2:$B). Unfortunately, COUNTIF doesn't take a third parameter.

So below, COUNTIF for activity 1 would be 3 since there are three value cells with activity 1. For activity 2, it would be 2.

NOTE: I've tried something like =IF($A2:$A=1, COUNTA($B2:$B),""), but this just counts all text values in range regardless of criteria of adjacent cell.

enter image description here

1
@player0 they're a lookup from elsewhere. Why?Growler

1 Answers

1
votes
=QUERY(A2:B, "select A, count(A) where A is not null group by A label A 'ID'", 0)

if you want only pure count use:

=QUERY(A2:B, "count(A) where A is not null group by A label count(A)''", 0)