Let’s say you have an array like this:

[
  1,
  2,
  3,
  4,
  5,
  6,
  7,
  8,
  9,
  10
]

And you would like to create slices of this array which contain not more than 3 elements each:

[
  [1, 2, 3],
  [4, 5, 6],
  [7, 8, 8],
  [10]
]

In order to solve this type of problem, I have seen people to resort to JavaScript, Azure Functions or complicated contraptions within Logic Apps. The alternative is to use a surprisingly little known expression function called chunk(): chunk() - Reference guide for expression functions - Azure Logic Apps.

The function takes two elements. The first is the array, that needs to be sliced, and the second is the slice length.

chunk('[1,2,3,4,5,6,7,8,9,10]', 3)

logic apps chunk

See here for the full workflow definition of this example:

See Gist on Github