Skip to main content
Power Automate
    • Connectors
    • Templates
    • Take a guided tour
    • Digital process automation
    • Robotic process automation
    • Business process automation
    • Process Mining
    • AI Builder
  • Pricing
  • Partners
    • Blog
    • Documentation
    • Roadmap
    • Self-paced learning
    • Webinar
    • Business process and workflow automation topics
    • Overview
    • Issues
    • Give feedback
    • Overview
    • Forums
    • Galleries
    • Submit ideas
    • User groups
    • Register
    • ·
    • Sign in
    • ·
    • Help
    Go To
    • Microsoft Power Automate Community
    • Welcome to the Community!
    • News & Announcements
    • Get Help with Power Automate
    • General Power Automate Discussion
    • Using Connectors
    • Building Flows
    • Using Flows
    • Power Automate Desktop
    • Process Mining
    • AI Builder
    • Power Automate Mobile App
    • Translation Quality Feedback
    • Connector Development
    • Power Platform Integration - Better Together!
    • Power Platform Integrations
    • Power Platform and Dynamics 365 Integrations
    • Galleries
    • Community Connections & How-To Videos
    • Webinars and Video Gallery
    • Power Automate Cookbook
    • Events
    • 2021 MSBizAppsSummit Gallery
    • 2020 MSBizAppsSummit Gallery
    • 2019 MSBizAppsSummit Gallery
    • Community Engagement
    • Community AMA
    • Community Blog
    • Power Automate Community Blog
    • Community Support
    • Community Accounts & Registration
    • Using the Community
    • Community Feedback
    cancel
    Turn on suggestions
    Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.
    Showing results for 
    Search instead for 
    Did you mean: 
    • Microsoft Power Automate Community
    • Galleries
    • Power Automate Cookbook
    • Excel Batch Create, Update, and Upsert

    Excel Batch Create, Update, and Upsert

    06-13-2022 09:31 AM - last edited 11-18-2023 10:59 AM

    Super User takolota
    Super User
    107295 Views
    LinkedIn LinkedIn Facebook Facebook Twitter Twitter
    takolota
    Super User takolota
    Super User
    • Mark as New
    • Bookmark
    • Subscribe
    • Mute
    • Subscribe to RSS Feed
    • Permalink
    • Print
    • Report Inappropriate Content

    Excel Batch Create, Update, and Upsert

    ‎06-13-2022 09:31 AM

    Update & Create Excel Records 50-100x Faster

    I was able to develop an Office Script to update rows and an Office Scripts to create rows from Power Automate array data. So instead of a flow creating a new action API call for each individual row update or creation, this flow can just send an array of new data and the Office Scripts will match up primary key values, update each row it finds, then create the rows it doesn't find.
    And these Scripts do not require manually entering or changing any column names in the Script code.

     

    • In testing for batches of 1000 updates or creates, it's doing ~2500 row updates or creates per minute, 50x faster than the standard Excel create row or update row actions at max 50 concurrency. And it accomplished all the creates or updates with less than 25 actions or only 2.5% of the standard 1000 action API calls.

     

    • The Run Script code for processing data has 2 modes, the Mode 2 batch method that saves & updates a new instance of the table before posting batches of table ranges back to Excel & the Mode 1 row by row update calling on the Excel table.
    The Mode 2 script batch processing method will activate for creates & updates on tables less than 1 million cells. It does encounter more errors with larger tables because it is loading & working with the entire table in memory.
    Shoutout to Sudhi Ramamurthy for this great batch processing addition to the template!
    Code Write-Up: https://docs.microsoft.com/en-us/office/dev/scripts/resources/samples/write-large-dataset
    Video: https://youtu.be/BP9Kp0Ltj7U

    The Mode 1 script row by row method will activate for Excel tables with more than 1 million cells. But it is still limited by batch file size so updates & creates on larger tables will need to run with smaller cloud flow batch sizes of less than 1000 in a Do until loop. 
    The Mode 1 row by row method is also used when the ForceMode1Processing field is set to Yes.

     

    Be aware that some characters in column names, like \ / - _ . : ; ( ) & $ may cause errors when processing the data. Also backslashes \ in the data, which are usually used to escape characters in strings, may cause errors when processing the JSON.

     

    Office Script Code
    (Also included in a Compose action at the top of the template flow)

    Batch Update Script Code: https://drive.google.com/file/d/1kfzd2NX9nr9K8hBcxy60ipryAN4koStw/view?usp=sharing
    Batch Create Script Code: https://drive.google.com/file/d/13OeFdl7em8IkXsti45ZK9hqDGE420wE9/view?usp=sharing

    You can download the Version 5 of this template attached to this post, copy the Office Script codes into an online Excel instance, & try it out for yourself.
    -Open an online Excel workbook, go the the automate tab, select New Script, then copy & paste the Office Script code into the code editor. Do this for both the Batch Update and the Batch Create script code. You may want to name them BatchUpdateV6 & BatchCreateV5 appropriately.
    -Once you get the template flow into your environment, follow the notes in the flow to change the settings to your datasources, data, & office scripts.

     

    If you need just a batch update, then you can remove the batch create scope.
    If you need just a batch create, then you can replace the Run script Batch update rows action with the Run script Batch create rows action, delete the update script action, and remove the remaining batch create scope below it. Then any update data sent to the 1st Select GenerateUpdateData action will just be created, it won't check for rows to update.



    (ExcelBatchUpsertV5 is the core piece, ExcelBatchUpsertV5b includes a Do until loop set-up if you plan on updating and/or creating more than 1000 rows on large tables.)

     

    Anyone facing issues with the standard zip file import package method can check this post for an alternative method of importing the flow: Re: Excel Batch Create, Update, and Upsert - Page 33 - Power Platform Community (microsoft.com)

     

    Or this one: https://powerusers.microsoft.com/t5/Power-Automate-Cookbook/Excel-Batch-Create-Update-and-Upsert/m-p...



    Thanks for any feedback, & please subscribe to my YouTube channel (https://youtube.com/@tylerkolota?si=uEGKko1U8D29CJ86)

     

    watch?v=HiEU34Ix5gA

    ExcelBatchUpsertV5.5.zip
    ExcelBatchUpsertV5.5b.zip
    Labels:
    • Labels:
    • Button flows
    • Desktop flows
    • Scheduled flows
    Message 1 of 324
    107,295 Views
    21 Kudos
    Reply
    • All forum topics
    • Previous Topic
    • Next Topic
    • « Previous
      • 1
      • …
      • 31
      • 32
      • 33
    • Next »
    RC92
    RC92
    Frequent Visitor
    • Mark as New
    • Bookmark
    • Subscribe
    • Mute
    • Subscribe to RSS Feed
    • Permalink
    • Print
    • Report Inappropriate Content

    ‎09-15-2023 06:36 AM

    There are no formulas in either table. I do have some slicers on both sheets.

    Message 311 of 324
    553 Views
    0 Kudos
    Reply
    Aritrade
    Aritrade
    Frequent Visitor
    In response to RC92
    • Mark as New
    • Bookmark
    • Subscribe
    • Mute
    • Subscribe to RSS Feed
    • Permalink
    • Print
    • Report Inappropriate Content

    ‎09-15-2023 06:30 PM

    I had similar issue. Somehow it is associated with auto calculation. You can calculation mode to manual the run the flow but for me setting calculation mode to manual did not work from script. To recalculate you can use workbook.refreshalldataconnections() with script. Sometimes adding delay in between steps can also solve issues. 

    Message 312 of 324
    540 Views
    0 Kudos
    Reply
    javijuan
    javijuan Helper I
    Helper I
    • Mark as New
    • Bookmark
    • Subscribe
    • Mute
    • Subscribe to RSS Feed
    • Permalink
    • Print
    • Report Inappropriate Content

    ‎09-26-2023 11:16 AM

    Issue resolved. Thanks

    Message 313 of 324
    500 Views
    0 Kudos
    Reply
    takolota
    Super User takolota
    Super User
    • Mark as New
    • Bookmark
    • Subscribe
    • Mute
    • Subscribe to RSS Feed
    • Permalink
    • Print
    • Report Inappropriate Content

    ‎10-14-2023 04:43 PM

    @Yutao 

     

    I have another user, @CRMBidNotificat consistently running into 504 timeout errors again on a larger dataset with 16,000 updates. I just successfully ran his data through on my end though. So I suspect this may be another instance of Office Scripts performance degradation / issues when the activity / call traffic for Microsoft / Azure is higher in a given user's region. Are there any known limitations like these? Does Microsoft currently have insufficient infrastructure to maintain certain levels of performance on Office Scripts at peak usage hours in some regions?

    Thanks,

    Message 314 of 324
    409 Views
    0 Kudos
    Reply
    Yutao
    Microsoft Yutao
    Microsoft
    • Mark as New
    • Bookmark
    • Subscribe
    • Mute
    • Subscribe to RSS Feed
    • Permalink
    • Print
    • Report Inappropriate Content

    ‎10-17-2023 09:59 PM

    @takolota 

     

    Thanks for tagging me! That's a very good observation! It would help if @CRMBidNotificat could share the clientRequestIds of one or two those failed Run script actions so I can take a look at the logs on our side and see if there is anything that might have caused the latency.

     

    Yutao_0-1697605134052.png

     

    Message 315 of 324
    377 Views
    2 Kudos
    Reply
    CRMBidNotificat
    CRMBidNotificat
    Regular Visitor
    • Mark as New
    • Bookmark
    • Subscribe
    • Mute
    • Subscribe to RSS Feed
    • Permalink
    • Print
    • Report Inappropriate Content

    ‎10-19-2023 09:02 AM

    Hey all,

     

    Sorry for the late reply - @Yutao , See below for client requests:

    "4e457b8a-df05-40bb-9925-c6e13a54d044", 
    "52a1b1c1-e4c4-4422-a1cd-dbc33fc6e9d4",

     

    Message 316 of 324
    359 Views
    0 Kudos
    Reply
    maniu_86
    maniu_86
    Regular Visitor
    • Mark as New
    • Bookmark
    • Subscribe
    • Mute
    • Subscribe to RSS Feed
    • Permalink
    • Print
    • Report Inappropriate Content

    ‎10-21-2023 02:32 PM

    Hi,

    I am struggling with it for few hours already... I made it to filling up Run script...

     

    What should I put in updated data fields?

     

    maniu_86_1-1697923867476.png

     

     

     

    Message 317 of 324
    317 Views
    0 Kudos
    Reply
    maniu_86
    maniu_86
    Regular Visitor
    In response to maniu_86
    • Mark as New
    • Bookmark
    • Subscribe
    • Mute
    • Subscribe to RSS Feed
    • Permalink
    • Print
    • Report Inappropriate Content

    ‎10-21-2023 03:04 PM

    Never mind, I figured it out! I missed the moment on the YT video!

     

    BTW. It is awsome guide!!!

    Message 318 of 324
    307 Views
    2 Kudos
    Reply
    maniu_86
    maniu_86
    Regular Visitor
    • Mark as New
    • Bookmark
    • Subscribe
    • Mute
    • Subscribe to RSS Feed
    • Permalink
    • Print
    • Report Inappropriate Content

    ‎10-22-2023 04:26 AM

    Hi,

    I could use some help. My target table contains 1500 rows and 7 columns. The cells to be updated are in columns 3 to 5. Column 1 is key column, column 2 is just a name. Everything works great as long as I update small batches, e.g. 15 rows. It takes about 2 minutes. However, trying to update all the values ​​today, the flow has already been running for 30 minutes. In addition, OneDrive also hangs: Something's not right. The page you requested is temporarily unavailable. We apologize for the inconvenience, please check back in a few minutes.

     

    Edit: I set the batch size to 256 and noticed that these rows were updated but the next batch is no longer executed.

     

    Message 319 of 324
    289 Views
    0 Kudos
    Reply
    takolota
    Super User takolota
    Super User
    In response to maniu_86
    • Mark as New
    • Bookmark
    • Subscribe
    • Mute
    • Subscribe to RSS Feed
    • Permalink
    • Print
    • Report Inappropriate Content

    ‎10-24-2023 07:34 AM

    @maniu_86 

    Could you share some screenshots of the errors & the flow please? I assume you are using version b with the do-until loop.

    Message 320 of 324
    245 Views
    0 Kudos
    Reply
    • « Previous
      • 1
      • …
      • 31
      • 32
      • 33
    • Next »

    Power Platform

    • Overview
    • Power BI
    • Power Apps
    • Power Pages
    • Power Automate
    • Power Virtual Agents

    • Sign up free
    • Sign in

    Browse

    • Templates
    • Connectors
    • Partners

    Downloads

    • Mobile
    • Gateway

    Learn

    • Documentation
    • Learn
    • Support
    • Community
    • Give feedback
    • Blog
    • Pricing

    • © 2023 Microsoft
    • Contact us
    • Trademarks
    • Privacy & cookies
    • Manage cookies
    • Terms of use
    • Terms & conditions
    Consumer Privacy Act (CCPA) Opt-Out Icon Your Privacy Choices