I’m struggling to combine items in my n8n workflow because they end up in different runs within the same execution.
The Decide Next Lookup node determines which branch an item goes to.
Based on that decision, the item follows a specific lookup path, but eventually they all come back together at the Good? node, which decides whether the result is good enough or if we should try another lookup method.
Because of this loop, my Results CSV node shows multiple runs in a single execution (for example, 3 runs → 3 CSV files).
What I’d like instead is a single final CSV file that combines all finished items, no matter how many times they ended up going back to the “Decide” node.
Does anyone know the best pattern to aggregate those items into one CSV at the end?
I found other topics about the same issue but it did not solve my issue.
If I understand you correctly, your logic outputs a row of information. You then want to add it to a table, in your case a CSV file, then you want to call the entire worksheet. I do this with an n8n native datatable. (see attached image)
You should be able to do this with an ‘add row’ node, then when your run is done, do a ‘get many rows’ node.
However, I don’t have just one “logic” node like NoOp in the example, what should the merging code contain where it uses results.concat($(“NoOp”).all(0, i)); ? The “Done?” node?
I tried to move the main logic into a subworkflow but the issue is the same.
Because one item needs to go through the main logic again, this means “Decide Next Lookup” runs a 2nd time so there will be 2 runs for all the downstream nodes, including for the CSV output.
It seems that there is no way to merge all items at the end.
Is that just how n8n is intended to work?
I was able to fix my issue by breaking my original flow down into 2 sub workflows.
One containing the loop and one containing the main logic to do in the loop.
That seemed to do the trick.
Big thanks for @ramin1 for trying to solve my problem. Appreciate it.