Google Data Studio:如何将动态下拉控件的选择值关联至参数并用于BigQuery SQL查询
Solution: Link Dynamic Dropdown to Parameter for BigQuery SQL in Google Data Studio
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_nameyou 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)
- Name: Use
- Save the parameter.
2. Set Up the Dynamic Dropdown & Link to 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_namefield 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_nameparameter 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_namefield 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
相关产品推荐
相关产品推荐

