Connect to Google BigQuery

Connect Data Studio to BigQuery tables.

BigQuery is Google's fully managed, petabyte scale, low-cost analytics data warehouse. The Data Studio BigQuery connector allows you to access data from your BigQuery tables within Data Studio.

BigQuery is a paid product and you will incur BigQuery usage costs when accessing BigQuery through Data Studio.
In this article:

How to connect to BigQuery

You can can connect Data Studio to a single Google BigQuery table or view:

To connect

  1. Sign in to Data Studio.
  2. In the top left, click , then select Data Source.
  3. Select the BigQuery connector.
  4. Select a connection option (described below) and provide your connection details.
  5. In the upper right, click CONNECT.
    1. The data source fields panel appears.
    2. The data source is now connected to your data set.

Connection options

When creating a BigQuery data source, you can choose from the following options:

My Projects

Use this option to select a full table in a project to which you have access. The data source editor allows you to traverse the Project, Data Set, and Table hierarchy.

Shared Projects

Use this to access a shared data set, and use a different project for billing purposes.

To connect to a shared project:

  1. Select a billing project.
  2. Enter the shared project name.
  3. Select a data set and table.
  4. Click CONNECT.

Custom Query

Select the CUSTOM QUERY option to provide a SQL query instead of connecting to a single table. Data Studio uses this custom SQL as an inner select statement for each generated query to the database.

To use Custom Query, first select a project you have access to. This will be used for billing purposes. Next, input your SQL query.

Custom Query Syntax

The custom query syntax should follow the BigQuery SQL dialect with the following caveats:

  1. Comments in the SQL statement are not supported
  2. Field names and aliases in the SELECT statement must not contain a period (.) To work around this you can do one of the following:
    1. Below the query input field, uncheck Use Legacy SQL. This will cause your query to use standard SQL, which supports periods in field names and aliases. Learn more about the Standard SQL dialect.
    2. Uses aliases to replace each period with an underscore (_)

      SELECT category.product AS category_product FROM
    3. Create a view within BigQuery and reference the view in the SQL statement or select the view under My Projects.

You can use the BigQuery user interface to test that your query works, then copy and paste that query into Data Studio.

Custom query parameters

You can use parameters to give report users a way to customize the query. Use the same syntax as described for running parameterized queries in BigQuery.

To add a query parameter:

  1. In the body of your custom query, replace a hard-coded value with an identifier beginning with the @ character. For example: @param_name.
  2. Below the custom query editor, click ADD PARAMETER. The parameters in your query are listed below the editor.
  3. Click a parameter in the list to configure its options:
    1. Name. This is the parameter identifier.
    2. Display name. Determines how the parameter appears to report users.
    3. Data type. Determines the kind of data expected for the parameter.
    4. Input type. Determines how the parameter values are displayed in the data source's Parameters section.
    5. Default value. Report users can override this. If modifying the parameter has been turned off then the default value will be used.
    6. By default, parameters can be modified in reports. Uncheck the box to turn this off. Learn more about allowing data source parameters in reports.

Date parameters

You can use the following reserved parameters to pass the report's time frame to the query:

@DS_START_DATE sets the beginning of the time frame.

@DS_END_DATE sets the end of the time frame.

To use these date parameters:

  • Below the query editor, check the Enable date parameters option.
  • Be sure to use uppercase for the parameter names.
  • If your report includes a date range control, viewers can use that to request different starting and ending dates from the BigQuery data.
All parameter values are passed to BigQuery as strings. To handle them as dates, numbers, or other data types in BigQuery, be sure to use an appropriate conversion function, such as PARSE_DATE , PARSE_TIMESTAMP, or CAST.


Basic example:

SELECT word FROM `TABLE` WHERE corpus = @corpus;

Use a string with contains and a number:

AND attendance > @attendance LIMIT 100;

Use date parameters:

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);

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);

Public datasets

You can use this option to access BigQuery public datasets. BigQuery offers a number of public samples, where the dataset is shared, but not the project. To query this data, you must specify your own project, which will be used to bill for processing costs on the shared data.

Advanced options

Supported Locations

Specify the location in which the query will execute. Queries that run in a specific location may only reference data in that location. For data in US or EU, you may choose (unspecified) to run the query in the location where the data resides. If any other locations are shown, you must select the query location explicitly.

Override Billing Project ID

Specify a different Billing Project ID for this custom query.

Configuration options

Use _PARTITIONTIME as time dimension

This option appears when you select a date-partitioned table. By default, the data source uses the table's partition time as the date range dimension. Uncheck this option to use explicit date fields in the table as the date range dimension. Learn more about date-partitioned tables in BigQuery.

Google data integrations

Some Google products export data directly into BigQuery tables. When recognized, Data Studio will automatically enrich the fields to include common aggregations, calculations, and field names.

Google Analytics BigQuery export

When Data Studio encounters a table generated by Google Analytics BigQuery Export, the table will have a Google Analytics icon next to it. When selected, many of the common metrics found in Google Analytics will automatically be created as Data Studio fields.

Configure the data source

The data source fields panel is where you configure the data source by renaming fields and adding descriptions, adding calculated fields, and changing data types and aggregations. Learn more about working with data source fields.

Control who sees the data

In the upper right of the fields panel, you can change the data source credentials. Credentials control who can see the data provided by this data source.

USING OWNER'S CREDENTIALS lets other people view or create reports that use this data without requiring them to have their own access to the data set.

USING VIEWER'S CREDENTIALS, on the other hand, requires each user of the data source to provide their own credentials to access the data set.

Learn more about data source credentials.

Create a new report from the data source

  1. In the upper right, click CREATE REPORT.
    1. The report editor appears.
  2. Click ADD TO REPORT.
    1. This adds the data source to report.
    2. You can now create charts and controls that get their data from this data source.

New to Data Studio?

Take the Create a report tutorial. Or learn more about the report editor.


BigQuery is a paid product and you will incur BigQuery usage costs when accessing BigQuery through DataStudio. Data Studio will issue queries to BigQuery during report editing, report caching, and occasionally during report viewing.

Learn more about setting up a BigQuery billing account.

Multi-day Tables

BigQuery supports querying across multiple tables, where each table has a single day of data. The tables have the format of YYYYMMDD. When Data Studio encounters a table that has the format of YYYYMMDD, the table will be marked as a multi-day table and only the name prefix_YYYYMMDD will be displayed in the table select.

When a chart is created to visualize this table, Data Studio will automatically create a default date range of the last 28 days, and properly query the last 28 tables. You can configure this setting by editing the report, selecting the chart, then adjust the Date Range properties in the chart's DATA tab.


To speed up the user experience, Data Studio Reports will try to asynchronously fetch data from BigQuery every 12 hours by default. Each of these fetches can incur BigQuery costs.

Caching and Report Viewing

Once the data is cached, when a report is viewed, Data Studio will try to access the data from cache, and therefore minimize BigQuery costs.

Caching is a best effort feature and might not always be possible depending on query response size.

Learn more about the cache.

Viewing SQL issued to BigQuery

You can view all the BigQuery SQL Data Studio generates from within the BigQuery Query History user interface.

Record Count metric

BigQuery data sources automatically provide a default Record Count metric. You can use this to breakdown your dimensions to show the number of records being aggregated by your charts.

Quotas and limits

BigQuery data sources are subject to the same rate limits and quota limits as BigQuery itself.

Was this helpful?
How can we improve it?