Custom SOQL Dashboard Data Extractor
Salesforce action: ExecuteSOQLQuery. Runs parameterized SOQL queries on a schedule (e.g., pipeline by region, top deals by amount), writes structured results to Excel workbooks on SharePoint for Power BI dashboard refresh.
Provided as-is, without warranty of any kind. Review and test each pattern in a non-production environment before deploying it to live automations. See our Terms.
Overview
This scheduled weekly flow executes parameterized SOQL queries against Salesforce and writes the structured results to an Excel workbook on SharePoint. The output is designed for Power BI dashboard refresh — providing a reliable, automated pipeline from Salesforce reporting data to Excel-based datasets.
Use Case
Sales leadership and executives need regularly refreshed views of the Salesforce pipeline without manually exporting reports. This flow automates the extract-to-Excel pipeline so Power BI dashboards always reflect the latest Salesforce data. The SOQL query is fully configurable via environment variable, enabling reuse for any Salesforce object or report scenario.
The flow is ideal for teams that:
- Weekly automated SOQL extraction — no manual report exports needed
- Excel output compatible with Power BI refresh — direct dashboard integration
- Fully configurable SOQL query via env var — no flow edits to change reports
- Timestamped metadata in Excel — ExtractDate, ReportName columns for audit trail
- Parallel row insertion — fast execution even with large result sets
Flow Architecture
Recurrence - Weekly (Monday, 6:00 AM EST)
RecurrenceFires once weekly on Monday at 6:00 AM Eastern.
7× parallel Initialize Variable
Initialize variableLoad env vars: SharePointSiteUrl, ExcelFilePath, ExcelTableName, SOQLQuery, ReportName; init RecordCount and ExtractDate.
Execute SOQL Query
Salesforce — ExecuteSOQLQueryRuns the parameterized SOQL query supplied by the flowlibs_SOQLDashboardQuery environment variable.
For Each Record
Apply to eachLoop through the SOQL query results.
Add Excel Row
Excel Online (Business) — AddRowV2Writes the record to the Excel table with 8 columns (ExtractDate, ReportName, RecordId, Name, StageName, Amount, CloseDate, OwnerId).
Increment Record Count
Increment variableTracks the running total of records extracted.
Compose Extract Summary
ComposeBuilds a summary string with report name, record count, and extraction timestamp.
Environment Variables
| Schema name | Type | Default | Description |
|---|---|---|---|
| flowlibs_SharePointSiteURL | String | <configure> | Target SharePoint site for the Excel output workbook (e.g., https://your-tenant.sharepoint.com/sites/Reporting). |
| flowlibs_SOQLDashboardExcelPath | String | /Shared Documents/FlowLibs - SOQL Dashboard.xlsx | Server-relative path to the Excel workbook that will receive the extracted rows. |
| flowlibs_SOQLDashboardTableName | String | SOQLDashboard | Name of the Excel table to write rows to. |
| flowlibs_SOQLDashboardQuery | String | SELECT Id, Name, StageName, Amount, CloseDate, OwnerId FROM Opportunity WHERE IsClosed = false ORDER BY CloseDate ASC | Parameterized SOQL query to execute. Default is open Opportunities ordered by CloseDate; replace with any valid SOQL query for your reporting scenario. |
| flowlibs_SOQLDashboardReportName | String | Open Pipeline by Close Date | Display name for the report in the ReportName metadata column on each extracted row. |
Connectors & Connections
| Connector | API name | Actions used |
|---|---|---|
| Salesforce | shared_salesforce | ExecuteSOQLQuery (Runs the parameterized SOQL query) |
| Excel Online (Business) | shared_excelonlinebusiness | AddRowV2 (Writes each record to the Excel table) |
| SharePoint | shared_sharepointonline |
Note — All connections are referenced as solution connection references; the flow is portable between environments as long as a connection is mapped at import time.
Customization Guide
Almost every realistic variant of this flow can be implemented by changing environment variable values. A few cases require small edits inside the flow definition — those are called out explicitly below.
- Change the SOQL query
- Update the flowlibs_SOQLDashboardQuery env var to any valid SOQL query. The flow extracts whatever columns the query returns — adjust the Add Excel Row mapping if you change the field list.
- Change the schedule
- Edit the Recurrence trigger to run daily, monthly, or at a different time of day to suit your dashboard refresh cadence.
- Target a different Excel file
- Update flowlibs_SOQLDashboardExcelPath and flowlibs_SOQLDashboardTableName to point to a different workbook or table on SharePoint.
- Add more columns
- Edit the Add Excel Row action to map additional SOQL fields to new Excel columns. Make sure the destination Excel table includes the new columns first.
- Deploy to another environment
- Import the solution, create the target Excel workbook on SharePoint with a table matching the column names (ExtractDate, ReportName, RecordId, Name, StageName, Amount, CloseDate, OwnerId), update the five env vars, bind the Salesforce and Excel connection references, then turn the flow on.
Key Expressions
The flow is intentionally light on Power Fx / WDL gymnastics — the heaviest expressions are the branch-name concatenation and the approval outcome check. They are listed below in the order they appear in the flow.
EXPR.01SOQL query parameter
Pulls the configurable SOQL query string from the environment variable so the flow can be retargeted without edits.
EXPR.02Null-safe field access (string)
Returns an empty string when the SOQL field is null, preventing failures when writing to Excel.
EXPR.03Null-safe field access (number)
Returns 0 when the SOQL numeric field is null, keeping Excel column types consistent.
EXPR.04Extract date/time
Formats the extraction timestamp written to the ExtractDate column on each row.
EXPR.05Summary concat
Builds the final summary string composed at the end of the run.
Comments
Sign in to join the conversation.
Sign inNo comments yet. Be the first to share your experience with this flow.