Using COUNTIF() in BigQuery

Happy weekend! Do you remember the good old COUNTIF from Excel?
When I was just starting out in Analytics and was working with spreadsheets, I would make heavy use of it.

Well, turns out we have something similar in BigQuery as well.

It's an aggregate function, counting only rows that fulfill a given condition, for example COUNTIF( a > 10 and b = 'text')

Of course, this would be pretty much the same as combining COUNT + CASE WHEN.

See a quick example below.

Found it useful? Subscribe to my Analytics newsletter at