简体   繁体   English

如何将 Data Studio 控件传递给 BigQuery 自定义查询

[英]How to pass Data Studio Controls to BigQuery custom query

I have the Data Studio Report in which I have Date and Task Controls.我有 Data Studio 报告,其中有日期和任务控件。

在此处输入图像描述

I am using custom BigQuery and have already set the date Control via date between @DS_START_DATE and @DS_END_DATE but I also need to set Task in the custom query.我正在使用自定义 BigQuery 并且已经通过date between @DS_START_DATE and @DS_END_DATE的日期设置日期控制,但我还需要在自定义查询中设置任务。

在此处输入图像描述

Note: I cannot use the parameter like Task = @Task because Task is a Control while adding parameter(@Task) is a completely different thing.注意:我不能使用像 Task = @Task 这样的参数,因为 Task 是一个控件,而添加参数(@Task)是完全不同的事情。

Update: The task is not a first-level filter.更新:该任务不是一级过滤器。 Somehow I need it to pass it in the subquery.不知何故我需要它在子查询中传递它。 I can pass the date in subquery via @DS_START_DATE and @DS_END_DATE but cannot do the same with Task.我可以通过@DS_START_DATE 和@DS_END_DATE 在子查询中传递日期,但不能对 Task 做同样的事情。

在此处输入图像描述

Thanks in advance:)提前致谢:)

Unless there is a specific requirement, your setup as it is should work.除非有特定要求,否则您的设置应该可以正常工作。 I'm assuming Task is a field in your data.我假设Task是您数据中的一个字段。 When the report viewer picks one or more values from the Task filter control, Data Studio will send the query to BigQuery with appropriate filter clause.当报告查看者从Task筛选器控件中选择一个或多个值时,Data Studio 会使用适当的筛选器子句将查询发送到 BigQuery。 You can confirm this by looking at the billing project's query history in BigQuery.您可以通过在 BigQuery 中查看计费项目的查询历史记录来确认这一点。

Edit(since OP has a specific requirement to add the parameter):编辑(因为OP有添加参数的特定要求):

  1. Create a task parameter in your data source.在数据源中创建task参数。 ( how to ) This can be text or single select . 如何)这可以是文本单个 select If it is single select , you will have to manually define the values.如果它是单个 select ,您将必须手动定义值。 Make sure this parameter can be modified by report editors.确保此参数可以由报表编辑器修改。
  2. In your query, add to the WHERE clause: WHERE task = @task在您的查询中,添加到WHERE子句: WHERE task = @task
  3. Add the appropriate control in the report and link it to the task parameters.在报告中添加适当的控件并将其链接到task参数。

This post has a similar example in the Creating parameterized custom queries section. 这篇文章创建参数化自定义查询部分有一个类似的例子。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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