Skip to content
Advertisement

Count BigQuery event.params based on event.key

I am attempting to count the events filtering on their parameter.

For example, suppose that I have the following. Here’s the real one for the inquisitive minds out there. https://i.imgur.com/rPwmR9i.png

event_params.key and event_params.value is an array of values. I need to filter out anything in that array that doesn’t match my key. In addition, I need to count each occurrence of a specific string value. I attempted to do something like the following:

It returns null for all columns. What I’m expecting to get would be something along the lines of this, horizontal or vertical, makes no difference.

Expected Output

Each Count per column is derived from the value associated with some_key in the above example. The value is static, from a list that is known. For example, the value for relationship_gender could be Male, Female, etc.. and I’d compare to match that.

Advertisement

Answer

I would generally structure your query like this:

You might have to make some adjustments based on if the things you want to count are in the string_value or int_value format. If you have a unique event_id, I would count distinct that instead of summing 1s.

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement