How to merge every 2 records into one row

Illustrated in the below image is an example of a flow with the Record Generator step as the source step.

In the below image, the Record Generator is populated with a field where the value will have a number next to it and the record will be generated 10 times.

image

The below page is the output of the records that were generated from the Record Generator step.

image

In the calculator step shown in the below image, “rowNumber/2” is used to reference every 2 records that is in the sequence and “group” is the created field for the records.

image

Below is the code for you to copy and paste in your calculator step:

let inputRecord = input.record
inputRecord.group=Math.ceil(input.rowNumber/2)
return inputRecord;

Illustrated in the below image is the Group step, with the created field “group” being used as a reference to group the records.

image

As shown in the below image, every 2 records are merged into one row.