“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.
Once you have the number you can split it by 2 to get the half.
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.
Update: you can use also the chunk(…) expression to split an array.
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.
Enable the concurrency control on both the loops and you can process up to 100 items at the same time.
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.