web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Flow to call an Office...
Power Automate
Suggested Answer

Flow to call an Office Script and Refresh a Power Query Table

(1) ShareShare
ReportReport
Posted on by 79
I'm working on some basic reports that I'd like to completely automate within the MS Stack.
 
I have a number of flows already set up that grab data reports received via email and uploads them into a dedicated SharePoint site.
 
From there, I have various excel working "reporting templates" of various complexity that also live in a SharePoint site. The automation I'm focused on for now is a simple report that is just a straight query refresh and the output table is the actual report.
 
The flow I'm working on would:
 
  1. Trigger at a scheduled time
  2. Call an office script that is supposed to refresh the query and place a time stamp on a sheet for the last refresh
  3. Delay to allow time for the query to refresh
  4. Get the file metadata
  5. Delay again to ensure the correct version has been synced with SharePoint
  6. Condition based on the data output from the table
    1. If there is no data in the table, send an email saying "nothings here"
    2. If there is data in the table, select specific columns, convert to an HTML table with certain formatting, and send an email saying "here is the data"
  7. Finally, update a SharePoint list with the date of the last successful flow run
 
The flow works, but my issue is actually with the office script being used. The script is:
 
function main(workbook: ExcelScript.Workbook) {

workbook.refreshAllDataConnections();

let sheet = workbook.getWorksheets()[0];

sheet.getRange("A1").setValue("Refreshing...");

sheet.getRange("A1").setValue(new Date().toISOString());

}
 
The timestamp of when the script is triggered populates, and the action in the flow shows as successful, but the query output table is wrong. When I go in and manually refresh the query the refresh works exactly as expected. I'll then delete a row or two and allow the flow to trigger, and the output table clearly doesn't refresh as the deleted rows are still missing but the query refresh should restore them.
 
Curious if anyone has an idea of how to effectively trigger a power query refresh through an office script or other means via power automate.
 
Appreciate any assistance. Thanks!
I have the same question (0)
  • Suggested answer
    wolenberg_ Profile Picture
    1,476 Super User 2026 Season 1 on at
    Hello there,
     
    Refreshing Power Query tables through Office Scripts is a bit more nuanced than calling workbook.refreshAllDataConnections(). That method triggers connections, but Power Query refreshes don’t always complete synchronously which is why your flow shows success and updates the timestamp, but the query output table isn’t actually refreshed when Power Automate checks it.
     
    Your script is firing but not waiting for the query to finish. Use query.refresh() for the specific Power Query, and add a delay or loop in Power Automate to ensure the data is ready before you process it.

     

    Helpful references

     

    ✨ If my response helped resolve your issue, please mark it as ✅ Accepted Answer and give it a ❤️ like — it helps others in the community find solutions fasterpted Answer and give it a ❤️ like — it helps others in the community find solutions faster. Thank you!


     
  • Suggested answer
    FlowingBuckle Profile Picture
    79 on at
    Hey @wolenberg_ - apparently this thread got posted twice.
     
    After some tips on my other thread on this same topic and a little more digging/testing, it became clear that Office Scripts do not support triggering power query refreshes unless the source is from Power BI. This is a known limitation and there's no official word on when, or if, Microsoft will expand this capability. 
     
    So the short answer is what I'm trying to accomplish is not possible with the current tools I have available. I could leverage a PA Desktop flow that opens an excel workbook where the queries are set to refresh upon opening, but using that method goes against the core foundation of my reporting structure where I try to make it so myself or any other user on my team could run reports if needed.
     
    Appreciate the input, but I believe this scenario is essentially solved even if the solution isn't what I was hoping for.
  • wolenberg_ Profile Picture
    1,476 Super User 2026 Season 1 on at
    Hi, your conclusion is correct with the current toolset, full automation of Excel Power Query refreshes via Office Scripts isn’t possible. The only supported automation path is through Power BI or using a desktop agent workaround.
     
     
     

    ✨ If my response helped resolve your issue, please mark it as ✅ Accepted Answer and give it a ❤️ like — it helps others in the community find solutions faster. Thank you!


     

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the April Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Vish WR Profile Picture

Vish WR 959

#2
Valantis Profile Picture

Valantis 872

#3
Haque Profile Picture

Haque 589

Last 30 days Overall leaderboard