简体   繁体   中英

How to add a list of "permitted values" to a parameter by using a BigQuery connector in Data Studio?

I was wondering if there is a way to add a list of "permitted values" to a parameter in Data Studio by using a custom query / BigQuery connector?

There is an option to do it manually in the Data Studio UI: Permitted values through Data Studio UI

But I am looking for a solution to do it through SQL because I have to pass a long list of values that can be changed every day, so adding a list of values manually through the UI is impossible.

Is it possible to do it through a custom query?

Thank you!

You can add parameters to a custom SQL query in the connector, just like the following examples show

    SELECT word FROM `TABLE` WHERE corpus = @corpus;
    
    Use a string with contains and a number:
    
    SELECT * FROM `bigquery-public-data.baseball.games_post_wide`
    
    WHERE REGEXP_CONTAINS(gameId, @s)
    
    AND attendance > @attendance LIMIT 100;

    
    Use a multi-select string parameter. Note the use of UNNEST to flatten the list of values:
    
    SELECT * from user.users as user WHERE display_name in UNNEST(@name);

    
    Date parameter example:
    
    SELECT creation_date, age, display_name from user.users as user
    
    WHERE creation_date > PARSE_DATE('%Y%m%d', @DS_START_DATE)
    
    AND creation_date < PARSE_DATE('%Y%m%d', @DS_END_DATE);

    
    Email parameter example:
    
    Select * from Sales WHERE sales-rep-email = @DS_USER_EMAIL;

Here you can read more about using parameters in Data Studio

You do not need a custom query to define allowed Values if you want to Filter for them just set them up as a Dimension and add a Filter Control with an drop-down List. This will allow you to select the present Values and filter for them.

Let me know if this solves it for you

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM