@Majingcth ,
So
With({rows:CountRows(Mails)}
rows is a temporary value used inside with () function (i prefer not to repeat same function call like CountRows() here)
ForAll(
Sequence(RoundUp( rows/ 5,0)),
I calculate the number of batches of 5 items using RoundUp( rows/ 5,0).
Sequence() function create an array of numbers from 1 to .... max number of batches.
And ForAll iterates through resulting array to obtain a table.
With(
{
Last5: LastN(FirstN(Mails,5 * Value),If(Value>RoundDown(rows/ 5,0),Mod(rows,5),5))
},
Concat(Last5,Result & ";")
)
)
I took batch of 5 by batch of 5 and create a item in table.