You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Google Data Studio:如何将动态下拉控件的选择值关联至参数并用于BigQuery SQL查询

Absolutely! This is totally achievable in Google Data Studio (now rebranded as Looker Studio) — here's a step-by-step breakdown to make this work exactly as you want:

1. Create Your Custom Parameter

First, we need to set up the parameter that will hold the selected customer name:

  • Open your report, click Resources > Manage Parameters from the top menu.
  • Click Add Parameter and configure these settings:
    • Name: Use param_customer_name (this matches the @param_customer_name you want to use in SQL)
    • Data Type: Select Text (since customer names are string values)
    • Default Value: You can set this to something like 'All Customers' if you want a "view all" option, or leave it blank.
    • Allowable Values: Choose Any value (we’ll let the dropdown control what gets passed here)
  • Save the parameter.

Next, create the dynamic dropdown that pulls values from your customer_name field and syncs to the parameter:

  • Click Controls > Drop-down list from the toolbar to add a new dropdown.
  • In the right-hand Data panel, select your BigQuery data source, then drag the customer_name field into the Dimension slot. This automatically populates the dropdown with all unique customer names from your dataset (it’ll update dynamically as your data changes).
  • Now, switch to the Control panel on the right. Look for the Link to parameter option, and select the param_customer_name parameter you just created.
  • That’s it! Now whenever a user selects a customer from the dropdown, the value is automatically passed to param_customer_name.

3. Use the Parameter in Your BigQuery SQL

Finally, reference the parameter in your BigQuery query to filter results based on the selected customer:
If you’re using a custom SQL data source, update your query to include the parameter like this:

SELECT *
FROM `your-project.your-dataset.your-table`
-- Filter for the selected customer, or show all if default "All Customers" is selected
WHERE customer_name = @param_customer_name 
   OR @param_customer_name = 'All Customers'
  • Make sure the parameter name in the SQL (@param_customer_name) exactly matches the one you created in Data Studio.
  • If you don’t need a "view all" option, you can simplify the WHERE clause to just WHERE customer_name = @param_customer_name.

Pro Tips

  • If your customer_name field has duplicate values, don’t worry — the dropdown will automatically show unique values only.
  • If you need to adjust the dropdown’s appearance (like adding a label), use the Style panel on the right to tweak it to your liking.

内容的提问来源于stack exchange,提问作者tacou_st

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.30 07:22:38