Importing Data from Salesforce to Google Sheets via SOQL

Published: September 26, 2025

G-Connector’s dynamic SOQL query builder is a powerful tool that can assist you in building your query.  It offers a variety of features suitable for all skill levels that make retrieving data from Salesforce into your spreadsheet quickly and easily.

How to retrieve data with Salesforce SOQL into Google Sheets

To get any data from Salesforce.com into your Google Spreadsheet using SOQL (Salesforce Object Query Language). Follow these easy steps:

  • Click Get Data Using Objects & Fields on the G-Connector for Salesforce add-on menu or Launch on the G-Connector for Salesforce add-on menu to display the side panel and then click Import Data -> Objects & Fields:

Import data
New from Objects and Fields
  • Select ‘Choose data to import’

    Choose data to import
  • The following dialog box will be displayed:

    Query dialog box

The Build your query dialog has three modes. Switch between them with the dropdown in the top-left corner of the dialog:

  • Objects & Fields: Pick an object, then select its fields, filters, and sorting.
  • Assistant: Describe the data you need in your own words, and the AI generates the query.
  • Query: Write or paste a SOQL query directly.

Assistant (Beta)

Describe the data you need in plain language, and the AI generates a SOQL query for you. This mode is a good choice if you know what data you want but aren’t sure which objects or fields hold it, or how to write the query.

  • Type your request in the Ask for the data you need… box and click the arrow to send it.
  • Or click a suggested prompt, such as Accounts with no activity in 90 days, to get started.
  • To build the query yourself instead, click Pick fields manually to switch to Objects & Fields mode, or Type in or paste raw SOQL to switch to Query mode.

The more specific your request, the better the result. Include the records you need, any conditions such as region, stage, or date range, and the fields you want returned. For example:

Show all open Opportunities in EMEA closing this quarter, including the Account name and Owner.

AI-generated queries may not always match your requirements exactly. Review the query and the data preview before importing.

Read more: https://www.xappex.com/knowledge-base/how-to-generate-soql-queries-with-ai-in-g-connector/

Query

Write or paste a SOQL query directly. This mode is for users comfortable with SOQL, and it gives you full control over the query. Any text in the query box runs as a SOQL query against the Salesforce org you’re logged in to.

Use Query mode for anything beyond what Objects & Fields mode can build, including:

  • Subqueries: Select Id, Name, (Select Id, Name From Opportunities) From Account
  • Fields from related objects: Select Id, Name, Account.Name, Account.Owner.Name From Opportunity
  • Filters based on another query: Select Id, Name From Account Where Id IN (Select AccountId From Opportunity Where Owner.Name = 'John Snow')
  • Values from your sheet: Enter a cell address or range in square brackets, and G-Connector uses those values in the query:
    • SELECT Id, Name FROM Opportunity WHERE Owner.Name = [Sheet1!C15]
    • SELECT Id, Name, StageName FROM Opportunity WHERE Id IN [Sheet1!A2:A20]

If you need help with SOQL syntax, see Salesforce’s SOQL documentation.

 

Objects & Fields

Objects & Fields

Build your query by selecting options instead of writing code. This mode is a good choice if you know which object you need but don’t want to write SOQL yourself.

  • Object: Choose the Salesforce object to pull data from, such as Account, Contact, or Opportunity.
  • Fields: Select the fields you want as columns in your sheet.
  • Filters: Add conditions to limit which records are returned, such as Stage equals Closed Won.
  • Sorting: Choose the field and direction to sort the results by.

Objects & Fields mode shows you your Salesforce schema, so you always use the correct object names, field names, and picklist values.

 

Query builder controls
  • You can use the query builder controls to put together a simple query with one filter.

    However, if you need to have more filters or want to use subqueries – you’ll need to type them in. Here are just a couple of query examples that you won’t be able to build using query builder controls, but can still use in the query box to retrieve data into your spreadsheet:

    • Select Id, Name, (Select Id, Name From Opportunities) From Account
    • Select Id, Name, Account.Id, Account.Name, Account.Owner.Name From Opportunity
    • Select Id, Name From Account Where Id IN (Select AccountId From Opportunity Where Owner.Name = ‘John Snow’)

    You can also reference existing values in your spreadsheet by specifying the cell address in square brackets, for example:

    SELECT Id, Name FROM Opportunity WHERE Owner.Name = [Sheet1!C15]

    or

    SELECT Id, Name, StageName FROM Opportunity WHERE Id IN [Sheet1!A2:A20]

Explaining the options for SOQL query building

  • Destination

    • Sheet: Picks the tab where the results go. New sheet creates a fresh tab for this import. Choosing an existing sheet writes into it, which is useful when you already have a report layout built around the data.
    • Start cell: The anchor cell for the header row; data flows down and to the right from there. Change it from A1 if you need space above or to the left for titles, notes, or summary formulas.
Destination

Data

  • Field labels as column headers: When checked, headers show the user-friendly field labels you see in the Salesforce UI, such as “Account Name” or “Close Date”. When unchecked, headers use API names such as Name, CloseDate, or Custom_Field__c. API names are handier if you’ll reuse the sheet for updates or share it with admins.
  • Include deleted and archived records: Runs the query in “query all” mode. The results then include records sitting in the Recycle Bin and archived activities, such as Tasks and Events Salesforce has archived. This is useful for audits, data recovery, or historical reporting. Leave it off for everyday reports, or you’ll get records users consider gone.
  • Nested records as columns: Applies when the query includes child relationships, such as Contacts under Accounts. By default each child record gets its own row and the parent data repeats. With this option, child records are laid out across columns on the parent’s single row. That keeps one row per parent, which reads more easily for summaries but gets wide when parents have many children.
Data

On refresh (what happens when you re-run the import)

  • Overwrite: The default. It clears the previous results and writes the current Salesforce data in the same place. Best for live reports that should always reflect the latest data.
  • Create new sheet: Every refresh writes to a new tab and leaves the previous ones untouched. Useful for point-in-time snapshots, such as a weekly pipeline copy you want to compare over time.
  • Append below existing data: New results are added under what’s already there instead of replacing it. Good for building a running log or history table, ideally with a date or timestamp column to tell runs apart.
  • Keep rows aligned (smart refresh): when this box is checked, the query refresh will update existing sheet rows at their positions using record ID. New rows will be added at the end, and missing sheet rows will be removed. Salesforce record ID must be present in the data source to identify the rows and use this feature.This will let you have custom data columns that are not present in Salesforce next to your Salesforce data rows and they will always remain aligned! Also any sorting applied to the data in the spreadsheet will remain unaffected on refresh, even if the source data is sorted differently.
On refresh

Sheet

  • Freeze header row: Freezes the header row so column names stay visible as you scroll through large datasets.
  • Toolbar in first row: Inserts a row above the headers with quick controls and info for this query. This makes the sheet easier to work with for users who don’t open the add-on sidebar. It shifts the data down one row.
  • Drop-downs for picklist fields: Applies data validation to picklist columns using the field’s allowed values from Salesforce. Users pick valid values instead of typing them, which matters if the sheet will be used to edit and push updates back to Salesforce.
  • Link record Ids to Salesforce: Turns Id cells into hyperlinks that open the record directly in Salesforce. It’s a quick way to jump from the sheet to the record.
  • Auto-fill formulas: If you have formulas in columns next to the imported data, they’re automatically extended to every row after a refresh. Calculations then keep working as the record count grows or shrinks.
  • Last refresh time cell: Enter a cell reference, such as A1, or a named range, and G-Connector writes the date and time of the last refresh there. This is useful on dashboards so viewers know how fresh the data is.
  • Auto-run: Lets you schedule the import to refresh automatically, for example hourly, daily, or weekly. It runs without anyone opening the sheet, so reports stay current on their own. It’s shown as Disabled here, meaning the import only refreshes when someone runs it manually.
Sheet

Once a query is executed, it will show up as a card under the Import Data button and it will be possible to run and delete it from there.

SOQL card
flash-icon Need Help?

We’re Here for You!

Try our powerful Salesforce data tools for free or upgrade for full access. Simplify data management and boost efficiency today!

By pressing 'Submit Form' you agree to our Privacy Policy