Yes, Power Automate can refresh an Excel Power Query, but a cloud flow cannot do it with a built-in Power Query refresh action. For dependable automation, use Power Automate Desktop to open the workbook in Excel for Windows and refresh it; Office Scripts have an important limitation for Power Query connections.
What Power Automate Can and Cannot Refresh
Power Query is Excel’s tool for connecting to sources, shaping data, and loading the results into a worksheet or the Data Model. In desktop Excel, the usual manual command is Data > Refresh All. A flow can automate the process indirectly, but the standard Excel Online (Business) connector does not provide a dedicated action that means “refresh this workbook’s Power Query.”
This matters because common flow actions such as adding a row to a table, reading a table, or running an Office Script are not equivalent to refreshing a query. A file being created or changed in OneDrive or SharePoint also does not, by itself, cause its queries to run. The flow needs a refresh method that Excel and the query’s connection can actually carry out.
For a workbook that must refresh its Power Query data, the most predictable general-purpose approach is to have a Windows machine run Excel desktop through Power Automate Desktop. A cloud flow can still handle the schedule or trigger, but the desktop flow does the Excel refresh. Whether that is the right setup depends on the workbook, its sources, and where it is stored.
Why Office Scripts Are Not a General Power Query Refresh Solution
Power Automate cloud flows can run Office Scripts against workbooks stored in OneDrive for Business or SharePoint. That can be useful for editing cells, formatting a table, or automating supported workbook operations. However, the Office Scripts method named refreshAllDataConnections() is not a universal way to refresh Excel Power Query.
Microsoft documents that this method refreshes only data connections supported by Power BI. It does not refresh most Power Query connections in an Excel workbook. A script may complete successfully while the query output remains unchanged, which can make this limitation easy to miss. Do not treat a successful “Run script” action as proof that the query refreshed; check the data or a refresh timestamp.
Excel for the web has its own ability to refresh some queries, depending on the source, connection, and authentication. That does not mean a cloud flow can invoke every web refresh capability through Office Scripts. If you are considering a script-based design, test the exact workbook and connector in your tenant before relying on it. For a workflow that cannot tolerate stale data, use a refresh route that is supported for the workbook’s connections.
Refresh with Power Automate Desktop and Excel for Windows
Power Automate Desktop can automate Excel installed on a Windows computer. A desktop flow can open the workbook, run a macro or use Excel’s interface to issue a refresh, wait for completion, save, and close the file. The computer must be available to run the flow, and Excel must be able to access the workbook and its data sources.
A typical setup looks like this:
- Store the workbook where the Windows machine can access it, such as a synchronized SharePoint or OneDrive folder, or a network location available to that machine.
- Create a desktop flow that launches Excel and opens the intended workbook. Use a known path and account rather than relying on a workbook already being open interactively.
- Run the workbook’s refresh operation. A desktop flow can use Excel’s interface, or use the Excel macro action if the workbook contains an approved macro.
- Wait for refresh activity to finish, then verify a result such as a refresh-time cell, expected row count, or a value from the refreshed output.
- Save and close the workbook, then let the flow report success or failure to the calling cloud flow.
For a macro-based approach, Excel’s Workbook.RefreshAll method requests a refresh of the workbook’s external data ranges and PivotTable reports. Some connections refresh in the background, so the macro returning does not necessarily mean every result is ready. The flow should include a suitable wait and a check for completion rather than immediately saving and assuming the data is current. If macros are used, save a backup copy first; macro changes cannot be undone with Ctrl+Z.
Power Automate Desktop can be run manually, on a schedule, or as part of a cloud-flow design, subject to the organization’s Power Automate licensing and machine configuration. Unattended execution has additional setup and licensing considerations. Do not assume a personal laptop that is shut down or signed out will run a scheduled refresh.
Prepare the Workbook and Connections Before Automating
A flow cannot solve a connection problem that would also stop a manual refresh. Before scheduling automation, open the workbook in desktop Excel and select Data > Refresh All. Confirm that the queries finish successfully, produce the expected output, and can authenticate without someone having to intervene.
In Excel for Microsoft 365 on Windows, Data > Queries & Connections opens the pane for inspecting queries and connections. You can right-click a query and choose Properties to review available refresh behavior, such as refreshing when the file opens or refreshing at an interval while the workbook is open. Those settings are useful context, but they are not a substitute for a flow that opens the workbook: an interval refresh does not run while Excel is closed.
Check the following details in particular:
- Credentials: The account running the flow must have permission to the source. A connection that works under your interactive account may fail under a different Windows or service account.
- Source availability: Confirm that websites, databases, files, and network shares are reachable from the machine that will refresh the workbook.
- Gateways and network access: Some on-premises sources require a gateway or access from the machine itself. A cloud flow’s access to SharePoint does not automatically give desktop Excel access to a private database.
- Query dependencies: Queries may reference other queries. Test the workbook’s complete refresh sequence, not just one visible output table.
- Load destination: Confirm that the query loads to the worksheet or Data Model your downstream process expects. A connection-only query may refresh without visibly changing a sheet.
- File contention: Avoid having people edit the workbook while the flow refreshes and saves it. Concurrent edits or an existing lock can cause errors or overwrite newer changes.
How to Make a Scheduled Refresh More Reliable
Design the flow so it can distinguish a completed refresh from a merely opened workbook. A fixed delay is simple, but query times vary with source size, network speed, and server load. If possible, have the automation check a value that changes only after successful refresh. For example, a query can include a source-side update timestamp, or the workbook can record the last completed run after the refresh has been verified.
Plan for failures as well as the normal path. If a connection times out or credentials expire, the flow should notify an owner and avoid presenting an old output as fresh. Logging the start time, completion time, workbook path, and error message makes it easier to diagnose whether a run failed to open Excel, reach the source, refresh a query, or save the file.
Think about where the refreshed file is consumed. A cloud flow that reads a table immediately after a desktop refresh may run before the desktop flow has saved or released the workbook. Make the desktop flow report completion to the cloud flow, or otherwise coordinate the sequence. Keep a backup or version history for important workbooks, especially when automation writes to a shared file.
Common Problems and What They Usually Mean
If the flow reports success but the results are old, first establish whether the refresh command actually ran. With Office Scripts, the connection may not be one of the Power BI-supported connections that refreshAllDataConnections() handles. With desktop automation, the flow may have clicked the wrong workbook, refreshed only the active sheet, or saved before a background query completed.
If Excel asks for credentials, the account used by the automation may not have a saved or usable sign-in for the source. If a query works on your computer but not on the automation machine, check the machine’s network route, mapped drives, privacy settings, and source permissions. Use an accessible full path rather than a drive mapping that exists only in an interactive session.
If a workbook is locked or changes are missing after the flow runs, check for another Excel process or a person editing the same file. A refresh that changes worksheet tables can also affect formulas, PivotTables, or downstream steps that assume a fixed row count. Test with a copy and inspect the workbook after a complete run before enabling a production schedule.
Choosing Between Cloud Flows, Desktop Flows, and Other Options
Choose the approach based on the actual connection and the level of reliability you need, not just on whether the workbook is stored in the cloud.
- Use a cloud flow with Office Scripts when the task is ordinary workbook automation or the data connection is explicitly supported by the script refresh method. Do not assume it will refresh a Power Query connection.
- Use Power Automate Desktop when the workbook must be refreshed by Excel for Windows and desktop Excel can reach its sources. This is often the practical option for existing workbooks with Power Query.
- Use Excel for the web manually when its refresh support covers the workbook’s sources and an attended refresh is acceptable. Test authentication and the specific queries in the browser.
- Move the data preparation elsewhere when the process needs a robust, server-side scheduled refresh rather than an Excel desktop session. Depending on the source and downstream use, a database, Power BI dataflow, or another managed data pipeline may be more appropriate.
Those alternatives are not interchangeable. A Power BI refresh updates a semantic model or dataflow; it does not automatically refresh an unrelated Excel workbook’s Power Query output. Likewise, moving a query to another service can require rebuilding transformations and changing permissions. Compare the total maintenance and access requirements before redesigning a working workbook.
Frequently Asked Questions
Can a cloud flow refresh Power Query directly?
No dedicated Excel Online (Business) action directly refreshes Power Query. Office Scripts can run in a cloud flow, but refreshAllDataConnections() is limited to supported Power BI data connections and is not a general Power Query refresh command.
Can Office Scripts refresh queries in Excel?
Not most Power Query connections. The documented refresh method supports Power BI data connections; test the exact connection rather than assuming the script refreshes every query in the workbook.
Can Power Automate Desktop refresh a workbook?
Yes. A desktop flow can open the workbook in Excel for Windows and trigger a refresh through Excel’s interface or an approved macro. It must wait for the queries to finish and save the workbook afterward.
Will Refresh All run if the workbook is closed?
Not by itself. Refresh All is an Excel command, so an automation process must open the workbook in an environment capable of refreshing its connections.
Can I refresh Power Query in Excel for the web?
Excel for the web can refresh some queries, but support depends on the source and authentication. That capability does not make every query refreshable through a cloud flow or Office Script.
Does a SharePoint file update trigger a query refresh?
No. A file-created or file-modified trigger can start a flow, but the flow still needs to run a supported refresh method. A trigger alone does not execute the workbook’s Power Query.
Related
- Automatically Transpose Data in Excel: Methods That Work
- Average Date Calculation in Excel: Methods and Examples
- Auto-Update Calendar Excel Template: Setup and Fixes
Try it: the Date Difference Calculator: days, months, years and weekdays between two dates, with the DATEDIF formulas.
More in How-to basics
- Data Validation Testing: Methods and ExamplesData validation testing checks whether data meets defined rules for format, completeness, consistency, and acceptable values before it…
- How to Change a Date Format to a Custom Format in ExcelTo change a date to a custom format in Excel for Microsoft 365 on Windows, select the date…
- Track a Budget in Google Sheets: A Practical GuideTo track a budget in Google Sheets, make one tab for transactions and another for your monthly plan,…
- Import Multiple CSV Files into Excel: Fast MethodsTo import multiple CSV files into Excel for Microsoft 365 on Windows, put the files in one folder,…
- Google Sheets Merge Duplicates: What Actually WorksGoogle Sheets can remove duplicate rows, but it does not have a single command that intelligently merges duplicate…
- Flash Fill in Excel: How It Works and When to Use ItFlash Fill in Excel automatically completes a column when it recognizes a pattern in examples you provide. In…
Sources: Function behaviour and menu paths: Microsoft Support documentation for Excel. Method & sources
Spotted an error in this guide? Let us know.