Analyze BigQuery data within Sheets

You can access and analyze your BigQuery data within Google Sheets using data connectors.

You can analyze and share large datasets from your spreadsheet with the BigQuery data connector. You can also use the data connector to:

  • Collaborate with partners, analysts, or other stakeholders in a familiar spreadsheet interface. 
  • Ensure a single source of truth for data without having to create additional .csv exports.
  • Streamline your reporting and dashboard workflows.

What you need

To connect with BigQuery, you’ll need one of the following account types: 

  • G Suite Enterprise
  • G Suite Enterprise for Education
  • G Suite Essentials

Learn more about G Suite

The BigQuery data connector is only available for eligible work or school accounts, and you’re not signed in. 

Sign in to your work or school account

Step 1: Choose or add a billing project

To add or use a BigQuery project in Sheets, your project role in BigQuery must be:

  • bigquery.user OR
  • bigquery.jobUser and bigquery.dataViewer

Learn how to change permissions.

Find a project

  1. On your computer, open a spreadsheet in Google Sheets.
  2. In the menu at the top, click Data and then Data connectors and then BigQuery.
  3. Under "Billing project," click Select a project.

Step 2: Write & edit a query

  1. After you choose or add a billing project, click Write query.
  2. In the query editor, enter a query.
    • Note: To preview how much data your query scans, at the bottom right, click the Check mark Check mark.
  3. At the bottom right of the editor, click Insert results.

Note: There is a time limit for a query execution of 4 minutes and 30 seconds.

When you compare data in Sheets and BigQuery

To compare data, you might need to change the data type. For example, if a column is string data in BigQuery, then it must be plain text in Sheets to be compared correctly.

If the data type in the spreadsheet and BigQuery are different, you can:


  • When you run a query, your spreadsheet permissions are used, not the spreadsheet owner’s.
  • You can pull up to 10,000 rows per query from BigQuery.
  • Data that you pull from BigQuery is read-only.
  • Only standard SQL is supported by BigQuery. 
Add parameters to your query

To use the value of a cell in a query, set up a parameter.

  1. At the right side of the query editor, click Parameters and then Add.
  2. Enter a name for the parameter and the cell you want to reference.
  3. Click Add.

Schedule a refresh of your query

You can record a macro and add a trigger to automatically update your query on a specific tab.

Step 1: Record a macro to refresh your data

  1. On your computer, open a spreadsheet that contains data connected to BigQuery in Google Sheets.
  2. Record a macro from a different tab than the one you want to refresh.
  3. After you start recording, switch to the tab you want to refresh.
  4. At the bottom left, click Refresh.
  5. Click Save.

Step 2: Schedule your macro

  1. At the top, click Tools and then Script editor.
  2. At the top, click Edit and then Current project's triggers. 
  3. At the bottom right, click Add trigger and select your options.
  4. Click Save
Example queries

Simple query:



SUM(word_count) AS word_count



WHERE word IN ('me', 'I', 'you')

GROUP BY word;

Parameterized query:

SELECT SUM(kw_total)

FROM `bigquery-public-data.sunroof_solar.solar_potential_by_censustract`

WHERE state_name = @STATENAME;

  • With added parameter name set to ‘STATENAME’ and cell reference set to Sheet1!A3, which has the value of ‘New York’.

Change billing project or permissions

Change your billing project
  1. In the query editor, at the right, click Query settings.
  2. Under "Billing project," choose a project.
Change who can see & edit queries or results

The actions you can take depend on your project and spreadsheet permissions.

User actions in Sheets Required project role in BigQuery Required permissions in Sheets
Create or edit the BigQuery query bigquery.user OR bigquery.jobUser and bigquery.dataViewer Owner, editor
View the BigQuery query None Owner, editor, viewer
Refresh data from a BigQuery query bigquery.user OR bigquery.jobUser and bigquery.dataViewer Owner, editor
See fetched data from a BigQuery query None Owner, editor, viewer


  • Queries are run using the user's spreadsheet permissions, not the spreadsheet owner's.
  • Users outside the domain can only interact with a domain-owned-Sheet if the domain G Suite Administrator has allowed it.
Was this helpful?
How can we improve it?