The salesforce_report_search formula lets you fetch multiple rows of data from a Salesforce report, with the ability to apply optional filters and sorting. It's ideal when you want to pull filtered datasets from saved reports directly into your spreadsheet.
Demo
Syntax
=salesforce_report_search(report_name, fields, [filter_string], [settings])
Arguments
Argument | Required | Description |
report_name |
YES | The name of the Salesforce report you want to fetch from (e.g., "All Opportunities") |
fields | YES | A comma-separated list of fields to return (e.g., "Amount, Stage") or a cell range (e.g., B1:D1) |
filter_string | Optional | Conditions to filter the data (e.g., "Stage = Closed Won") |
settings | Optional | Comma-separated options like limit, include_header, or sort. Example: "limit=100,include_header=true,sort=Amount:desc" |
Field List Syntax (fields)
You can:
- List fields directly: "Opportunity Name, Amount, Stage"
- Use a cell range: A1:A3 or B1:D1
- Field names should match column headers in your Salesforce report
- Fields are case-insensitive, but matching the exact label from the report UI is recommended
Filter Syntax
- Simple filters: "Stage = Closed Won"
- Combine filters using "AND" or "OR": "Stage = Closed Won AND Amount > 50000"
- Use quotes for string values, no quotes for numbers
Settings
Setting | Description |
limit | Maximum number of rows to return (default: all). |
include_header | If true, includes the column headers as the first row. |
sort | Specify sort order: sort=Amount:desc, sort=CloseDate:asc |
Examples
Fetch the top 100 Closed Won opportunities with selected fields.
=salesforce_report_search("All Opportunities", "Opportunity Name, Amount, Stage", "Stage = Closed Won", "limit=100,sort=amount:desc")
Use a header range to define fields.
=salesforce_report_search("All Opportunities", B1:D1, "Stage = Closed Won")
Fetch all opportunities sorted by amount (descending).
=salesforce_report_search("All Opportunities", "Opportunity Name, Amount",,"sort=Amount:desc")
Best Practices & Tips:
- Great for exporting **full tables of report data**, especially when filtering on aggregated or summarized reports
- Ensure your Salesforce connection has access to the report you're referencing
- If you intend to use a NOT condition, you could use the `not in` operator listed above.
- E.g.: (Close Date <= Date Y AND Product Type not in Recurring)
Common Errors
Error Message | Cause |
Report not found | The report_name is incorrect or inaccessible. |
Salesforce connection requires reauth | Reauthorize your Salesforce connection via the sidebar. |
Internal error executing the custom function | Google Sheets timeout; try simplifying or re-executing the formula. |