Search code examples
google-bigquerylooker-studio

Can I set multiple strings as the parameter for SQL Query in Looker Studio?


I am trying to connect my data from BigQuery to Looker Studio. I want to filter an event based on the platforms (iOS, Android, Web). my Custom SQL Query in Looker Studio is like this

SELECT event_name, event_timestamp
FROM `project.analytics_111134888.events_*`
WHERE platform IN (@platform) <--- I use parameter in here

I define the @platfrom in Looker studio like this

enter image description here

I want to filter the query with these options. either select

  1. Android Only
  2. iOS Only
  3. Web Only
  4. All (Android + Web + iOS)

If Choose Single Select as the cardinality I will have no data show up on my Looker Studio if I choose All. If I change the cardinality to be Multi-Select then I can't even connect my BigQuery to Looker Studio, it will be error, maybe because the SQL type is ARRAY<STRING>

so, Can I set multiple strings as the parameter for SQL Query in Looker Studio? how to do something like that?


Solution

  • If I change the cardinality to be Multi-Select then I can't even connect my BigQuery to Looker Studio, it will be error, maybe because the SQL type is ARRAY<STRING>

    Would you try below for Multi-Select ?

    SELECT event_name, event_timestamp
    FROM `project.analytics_111134888.events_*`
    WHERE platform IN UNNEST(@platform) --<--- I use parameter in here
    

    Test Custom SQL

    SELECT platform
    FROM UNNEST(['ANDROID', 'IOS', 'WEB']) platform
    WHERE platform IN UNNEST(@platform) --<--- I use parameter in here
    

    enter image description here