Forum Discussion

AustinMB's avatar
AustinMB
New Member
10 months ago
Solved

Automate PQ Refresh?

I have a connection from a Power BI semantic model to my Excel work book via Get Data --> from power platform--> from Power BI.   the semantic model refreshes 6am daily. I'd like to schedule and au...
  • Aala_Ali's avatar
    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.

    1. Store the workbook on SharePoint/OneDrive.
    2. In each PivotTable: PivotTable Options → Data → Save source data with file ON (so Monday opens are instant).
    3. Create an Office Script that calls workbook.refreshAllDataConnections(), refreshes all PivotTables, and recalculates (script below).
    4. Build a Power Automate cloud flow (Recurrence → Sunday) to Run Script on the file. The file auto-saves server-side after the refresh.
    5. 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.