Forum Discussion
Automate PQ Refresh?
- 10 months ago
Hi AustinMB
Try to Schedule a Sunday refresh for your Excel workbook that’s connected to a Power BI semantic model using Power Automate + Office Scripts.- Store the workbook on SharePoint/OneDrive.
- In each PivotTable: PivotTable Options → Data → Save source data with file ON (so Monday opens are instant).
- Create an Office Script that calls workbook.refreshAllDataConnections(), refreshes all PivotTables, and recalculates (script below).
- Build a Power Automate cloud flow (Recurrence → Sunday) to Run Script on the file. The file auto-saves server-side after the refresh.
- Ensure the flow user has Build access on the dataset and edit rights on the file.
function main(workbook: ExcelScript.Workbook) { workbook.getApplication().setCalculationMode(ExcelScript.CalculationMode.automatic); workbook.refreshAllDataConnections(); workbook.getWorksheets().forEach(ws => ws.getPivotTables().forEach(p => p.refresh())); workbook.getApplication().calculate(ExcelScript.CalculationType.full); }
If Office Scripts are disabled, run the refresh on a VM with Power Automate Desktop (unattended) to open Excel → Refresh All → Save → Close on Sunday.
If this helps, please mark as Solution and drop a kudos so others can find it faster.
Note: Portions of this answer were edited with QuillBot for clarity.
Hi AustinMB
Try to Schedule a Sunday refresh for your Excel workbook that’s connected to a Power BI semantic model using Power Automate + Office Scripts.
- Store the workbook on SharePoint/OneDrive.
- In each PivotTable: PivotTable Options → Data → Save source data with file ON (so Monday opens are instant).
- Create an Office Script that calls workbook.refreshAllDataConnections(), refreshes all PivotTables, and recalculates (script below).
- Build a Power Automate cloud flow (Recurrence → Sunday) to Run Script on the file. The file auto-saves server-side after the refresh.
- Ensure the flow user has Build access on the dataset and edit rights on the file.
function main(workbook: ExcelScript.Workbook) { workbook.getApplication().setCalculationMode(ExcelScript.CalculationMode.automatic); workbook.refreshAllDataConnections(); workbook.getWorksheets().forEach(ws => ws.getPivotTables().forEach(p => p.refresh())); workbook.getApplication().calculate(ExcelScript.CalculationType.full); }
If Office Scripts are disabled, run the refresh on a VM with Power Automate Desktop (unattended) to open Excel → Refresh All → Save → Close on Sunday.
If this helps, please mark as Solution and drop a kudos so others can find it faster.
Note: Portions of this answer were edited with QuillBot for clarity.