# How to merge every 2 records into one row

**URL:** <https://community.synatic.com/t/how-to-merge-every-2-records-into-one-row/182>\
**Category:** Calculators\
**Tags:** calculator, helper-functions\
**Created:** [February 7, 2022, 12:06pm UTC](https://community.synatic.com/t/how-to-merge-every-2-records-into-one-row/182 "2022-02-07T12:06:58Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![navessa](https://yyz2.discourse-cdn.com/flex032/user_avatar/community.synatic.com/navessa/32/58_2.png) [@navessa](https://community.synatic.com/u/navessa)\
**Post date:** [February 7, 2022, 12:06pm UTC](https://community.synatic.com/t/how-to-merge-every-2-records-into-one-row/182/1 "2022-02-07T12:06:58Z")

</div>

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

 ![image](https://canada1.discourse-cdn.com/flex032/uploads/synatic/original/1X/5fc7c0a6a6ab5072ef9aff22a5b64faa609bb72a.png)

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](https://canada1.discourse-cdn.com/flex032/uploads/synatic/original/1X/54627b8a1da30a179241e95f58d5fb7d4206da45.png)

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

![image](https://canada1.discourse-cdn.com/flex032/uploads/synatic/original/1X/04b21ac82e00dfad11737017ff3d65bf1d225ee9.png)

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](https://canada1.discourse-cdn.com/flex032/uploads/synatic/original/1X/78268314be6d82aaf98c4338f3ec1e604379fbdb.png)

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](https://canada1.discourse-cdn.com/flex032/uploads/synatic/original/1X/c5db29eb853a2f25f9a63d93de8d4d88e180dde5.png)

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

 ![image](https://canada1.discourse-cdn.com/flex032/uploads/synatic/original/1X/7a42a5e415b33ad805f1d529e3727dc10b781b1a.png)
