Can't use values from the branches - using merge

Hello there,
I am current problem. Maybe I dont understand how joining branches works in n8n.
I tried to split the branches in my workflow (into 3 branches). each branch has their own number (1, 2, 3). I would like to use their values after I rejoin the branches into one and continue with the process. However I can only use 1 and 0 values. The other values from other branches can’t be found.

I also tried this workflow without Merge node, but It will make 3 runs and each run contain only 1 number, so i can’t use these from one place.

Please share your workflow


Edit Fields 0,1,2,3 are the same. Just containing one string according their number. Merge1 is set to Mode: Append and number of Inputs 3. 

Share the output returned by the last node

Here I can use values from 1 and 0. But I would like to use all the values that I used in an input.

Information on your n8n setup

  • n8n version: 1.106.3 (selfhosted)

Hey there!

You have 2 options here:

Option 1:

  • Set the Merge note to Append (as you do now)
  • Change the expressions as follows:
{{$(‘Merge’).all()[0].json['DATA 1']}}
{{$(‘Merge’).all()[1].json['DATA 2']}}
{{$(‘Merge’).all()[2].json['DATA 3']}}

This is needed because currently, the data from the Merge node comes in an array of json objects:

[
{"json":{"1":"DATA 1"},"pairedItem":{"item":0}},
{"json":{"2":"DATA 2"},"pairedItem":{"item":0,"input":1}},
{"json":{"3":"DATA 3"},"pairedItem":{"item":0,"input":2}}
]

The syntax you used accesses the first item from the array always, as it’s a shorthand syntax, not the full thing.

Option 2
(only works for the current data setup, if you change the actual data structure of the nodes it might not work as expected)

Hope this helps and don’t forget to mark it as Solution to help others in the future :handshake:

1 Like

Thank you so much. It is working :100:

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.