'Countif' type functionality in Looker?

Hi Looker Community,

Can you tell me if there is a looker function / statement that is equivalent to ‘=countif’ in excel? The reason I ask is because I want looker to be able to count the number of instances of a particular outcome in a custom field.

To give that some context, I am running a report that produces many rows of data - the size of which depends on the date range used.

One of the columns within that report is a ‘concatenation’ of four other columns, where the concatenated information is only displayed when it satisfies a yes/no condition via an ‘if statement’ (per a table calculation).

What I am desperately keen to do is to be able to count the number of times the concatenated results appear in the data (akin to countif in excel).

Hopefully this all makes sense (I’m a looker newbie) and there is a solution.

Many thanks,

Shaun

0 2 24.8K
2 REPLIES 2

Hello Shaun,

I’ve used this solution a few times:

sum(if(yourcondition,1,0)).

“yourcondition” is ${concatenatedcolumn}!="" if i understand you correctly.

This will count the number of rows that match you condition. Below is an example. You’ll have to change the condition of course.

Hi Jimmy,

Appreciate you taking the time to reply.

Unfortunately I haven’t had an opportunity to try your suggestion as yet, but certainly plan to in the coming 24 hours.

Many thanks!

Cheers,

Shaun

Top Labels in this Space