Let's POWER Automate

From no-code to low-code

Menu
  • Expressions
  • Filters
  • General
  • Application specific solutions
    • Dataverse
    • Excel
    • Forms
    • Planner
    • Outlook
    • SharePoint
    • Teams
  • Triggers
  • Resources
  • ABOUT ME
  • Get help with your flow
Menu

Split items array in halves for faster processing in Power Automate

Posted on September 7, 2022September 7, 2022 by Tom

“I feel limited by the 50 parallel runs in Power Automate, can I somehow split the input array into halves to process it faster?”


If you feel that your Power Automate flow spends too much time in a loop, you can enable concurrency. With a simple configuration in the ‘Apply to each’ action you can switch from serial loop into parallel loop. Instead of one item at a time it’ll process up to 50 items at once. But what if you need more? How do you split the input between multiple such loops? E.g. split an array in halves to run 2 such loops in parallel?

How many is the half?

To split an array into halves you must first know what the half is. Use the length(…) expression on the array to get the full size, e.g. all the returned SharePoint items.

length(outputs('Get_items')?['body/value'])

Once you have the number you can split it by 2 to get the half.

div(length(outputs('Get_items')?['body/value']),2)

Get the first and second half

Now you know how many items should each of the arrays have and you can split it. Use the same combination of the skip(…) and take(…) expressions as when splitting email recipients to create the two arrays.

First array, take the first half:

take(<array>, <half the items>)

e.g.
take(outputs('Get_items')?['body/value'],div(length(outputs('Get_items')?['body/value']),2))

Second array, skip the first half and take the rest:

skip(<array>, <half the items>)

e.g.
skip(outputs('Get_items')?['body/value'],div(length(outputs('Get_items')?['body/value']),2))

The arrays can be then used in the two ‘Apply to each’ actions running in parallel.

Power Automate split array halves

Enable the concurrency control on both the loops and you can process up to 100 items at the same time.

Summary

If you have a slow loop in your Power Automate flow, you might consider to split the input array in halves to make it a bit faster. Get the whole size of the array, divide it by two, and use that number to take(…) and skip(…) the corresponding number of items. All the steps in this example were combined into two expressions, but you can do it step by step using multiple ‘Compose’ if you’d like.

Just keep in mind that parallel loops and branches can mess up your variables, unless you prepare them for it.


Do you struggle with the various expressions, conditions, filters, or HTTP requests available in Power Automate?

I send one email per week with a summary of the new solutions, designed to help even non IT people to automate some of their repetitive tasks.

All subscribers have also access to resources like a SharePoint Filter Query cheat sheet or Date expressions cheat sheet.

Zero spam, unsubscribe anytime.

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Do you know what to do, but not how to do it?

Get The Ultimate Power Automate expressions cheat sheet and translate your thoughts into flows with ease!


There's also the HTTP requests to SharePoint cheat sheet to help you overcome limitations of some standard actions!

Do you struggle with the various expressions, conditions, filters, or HTTP requests available in Power Automate?

I send one email per week with a summary of the new solutions, designed to help even non IT people to automate some of their repetitive tasks.

All subscribers have also access to resources like a SharePoint Filter Query cheat sheet or Date expressions cheat sheet.

Zero spam, unsubscribe anytime.

  • How to find Excel rows missing in SharePoint list (Power Automate)March 29, 2023
  • Check whether user exists in AAD with Power AutomateMarch 26, 2023
  • How to highlight whole SharePoint row based on calculated dateMarch 22, 2023
  • Why is your Power Automate flow running so slow?March 19, 2023
  • How to add multiple links to the Power Automate approval taskMarch 15, 2023

Power Automate blogs worth visiting

Damien Bird
Dennis (Expiscornovus)
Paul Murana

©2023 Let's POWER Automate | Theme by SuperbThemes