Documentation
Apps
Guides
Merging Two Data Sets into One Table

Merging Two Data Sets into One Table

Using JavaScript to Merge Two Data Sets

  1. Create a dataflow.
  2. In [action1], retrieve data from the first data source.
  3. In [action2], retrieve data from the second data source.
  4. In [action3], select JavaScript and enter the following code:
const action1 = {{ action1.data }}
const action2 = {{ action2.data }}
const mergedData = []
 
for (let i = 0; i < action1.length; i++) {
  const id = action1[i].id
  const data1 = action1[i]
  const data2 = action2.find(d => d.id === id)
 
  if (data2) {
    mergedData.push({ ...data1, ...data2 })
  }
}
 
return mergedData
  1. Place a [Table].
  2. In [Data], enter {{ dataflow1.data }}.