Power Automate, the best way to write to Excel?

Power Automate, the best way to write to Excel?

A colleague of mine asked me for some advice on exporting a larger dataset to an excel table. His flow was using the add row action in a for all loop, and for 4000 rows it was taking over 4 hours. My immediate thought was to use a Office Script, but I realised not everyone is fluent with them, and it as and added complexity that might not be wanted. So I thought what is the best way?

I thought of 2 possible optimizations that might improve the process:

  • Concurrency
  • Version Control

The concurrency was the obvious choice, as surely writing 50 rows in parallel would be around 50 times faster. And the version control, well that was a guess, it shocked me that 4000 rows was taking so long, and my only thought to this was possible every add row was creating a version in SharePoint (why else would it be taking over 3 secs to add each row)

So it was time for an experiment, I was going to create 5 test cases and have a flow drag race.

No alt text provided for this image

The 5 test cases were:

  1. Simple Add row
  2. Add row with concurrency set to 50
  3. Simple Add row in library with no version controls
  4. Add row with concurrency set to 50 with no version controls
  5. Office Script

For the test I setup a simple flow which would generate a 4 field, 1000 row array with random data. Then run the 5 test cases in series to write the array to an empty excel table, one scope for each case

No alt text provided for this image
No alt text provided for this image
No alt text provided for this image

The office script was using same pattern, with a loop creating a row array and then adding the row.

No alt text provided for this image

So what was the result, well first, it took 5 minutes to create the 1000 rows of dummy data, Power Automate really isn't optimized for adding to arrays in any format! And well I was right, Office Script is best, by a long shot (only 9 Seconds). But what was interesting was the other optimizations.

No alt text provided for this image

Version control seemed to have impact, but not as significant as I thought, and why was concurrency higher than simple add row, it had 50 calls in parallel yet was slower.

No alt text provided for this image

At row 130 I found the issue, a 12 minute wait due to 7 retry attempts. The reason for the 6 fails was a 429 "Rate limit is exceeded".


We had hit the API limit (this wasn't the only row too), the Excel connector limit is 100 per minute (SharePoint has 600 and I thought Excel was the same).

No alt text provided for this image

But why had the no version control concurrency case not had the same issue, well it had, but the timeouts were significantly less.

So I re-ran the tests. And this time both 15 mins, then both 26, one 23 one 24, and so on. It turns out that it was very much luck of the draw, would Microsoft enforce the API limit, and how long timeout for. The version control was a red hearing and had no real impact.

So my next thought was, can I optimize the concurrency. With a 100 API limit, if I set the concurrency to 50 and add delay for 29 seconds, that would enforce 100 calls per minute (the theoretical consistent max). I ran this multiple times and consistently got just over the 10 minute mark.

No alt text provided for this image

So the results were in,

  1. Office Script were by far the best (with additional benefit of only using 1 Power Platform API request).
  2. Optimizing the Concurrency to hit 100 calls per minute was second best and good for anyone not wanting to use Office Scripts (with only negative the data table wasn't in original order).
  3. Using concurrency above that can is very inconsistent, with API timeouts sometimes almost doubling the entire time (I also suspect even the simple add row may occasional get some timeouts too).
  4. And my guess that version control had an impact was totally wrong.

Mihir Godbole, PMP, CSM

Intelligent Automation

2 年

Another possibly efficient option would be use desktop flow with Access DB engine - which can then allow you to use SQL(insert) queries against excel?

Tyler Kolota

Software Development & Process Improvement

2 年

If anyone is looking for an easier to use Office Script template for the fastest way to Create and/or Update Excel, then you can check this page: https://powerusers.microsoft.com/t5/Power-Automate-Cookbook/Excel-Batch-Create-Update-and-Upsert/td-p/1624706 It can help you create and/or update more than 1500 rows per minute.

要查看或添加评论,请登录

David Wyatt的更多文章

  • Power Automates Top 10 Missing Features

    Power Automates Top 10 Missing Features

    Power Automate is a fantastic piece of Software, with a perfect learning curve and extensive functionality. Anyone can…

  • Top 5 Ways to Optimize your Flows

    Top 5 Ways to Optimize your Flows

    Due to its enterprise use, parallel runs, and ample allowance, we never normally think about the need to optimize our…

  • 99 Admin Connectors Because 1 Just Wont Do

    99 Admin Connectors Because 1 Just Wont Do

    To support management and administration of the Power Platform Microsoft has taken an unusual approach. Where the…

    1 条评论
  • Power Apps, don't forget to read the small print

    Power Apps, don't forget to read the small print

    The undeniable power in the Power Platform is its 'Low Code, No Code' philosophy, which empowers anyone to create…

    1 条评论
  • Power Automate- Low code, More code (well just a little bit more)

    Power Automate- Low code, More code (well just a little bit more)

    The power of Power Automate is very much in its 'Low Code, No Code' philosophy, with its UI allowing anyone to quickly…

    1 条评论
  • Are Office Scripts the new VBA?

    Are Office Scripts the new VBA?

    There are many paths into software development, and I suspect a few will be similar to mine. With no formal education…

    1 条评论

社区洞察

其他会员也浏览了