Can't get data to drop to a single item after it runs through a loop. What am I doing wrong?

Describe the problem/error/question

data is entering the loop after I split it. (in this case it was 10 items)
it runs the loop and outputs 300+ items
after the loop I have an aggregate node set to all items into one and also execute once
but no matter what, it runs 10 times (depends on the input from the split node before the loop
I just want data down to a single item after the loop, i don’t care how it is accoimplished. if there is 10 items going into the loop, how do I reduce that to 1 after the loop is run?
I have tried filter, set, aggregate, all set to execute once, and nothing drop it down to 1 item

What is the error message (if any)?

Please share your workflow

Share the output returned by the last node

Information on your n8n setup

  • n8n version: self hosted 2.8.3
  • Database (default: SQLite): postgres
  • n8n EXECUTIONS_PROCESS setting (default: own, main):
  • Running n8n via (Docker, npm, n8n cloud, desktop app): docker
  • Operating system: Ubuntu 22.04.5
1 Like

Hi @djjace Welcome to the community!
I think linking your Aggregate node to the done output of Loop Over Items (not the loop output) and set it to “All Item Data (Into a Single List)” might work here, so after all iterations finish it emits a single item containing all processed items in one array. Repeat through products in total.

not quite sure I follow. I have the aggregate after the looping is done, but from how I am reading your post it would suggest there is another output I could link it to? I only have “loop” and “done” coming from the loop over items node

Can you share your workflow again after running it and pinning the data so we can see is there something wrong between it? Currently i have tested your flow with some random data i have generated and it seems to be working fine.

it is too big, but I shared it as a text via drive

I have tried everything I can to get it to 1 item.

If I have a aggregate node that has 12 items going into it, and I say “all items into one list” and have the execute once option toggled, I should not get 12 items as output, right?

ive done this a hundred times on other workflows and never had this issue before

hi @djjace I ran the exact same wf keeping only the pinned data from “edit fields“ and it worked well with a single output after the aggregate node :

JSON wf attached : can you run the same and let me know the output ?

wf debug 267483.json (72.3 KB)

Is there a setting somewhere that might cause this issue? I am at a complete standstill with my projects. this issue is on every workflow I have

Hi @djjace,

I can guess what’s wrong with this workflow, the Split node inside the loop outputs two branches, and each branch loops back, that explains why in the end the Aggregate node doesn’t return a single item..

The solution would be to use a Merge node so that we get only one loopback branch, keeping the loop logic correct,

However, I personally wouldn’t do that because it would make the workflow more complicated than necessary,

Usually, the first thing that comes to mind when I see a loop node is: Do I really need a loop?! Most of the time, the answer is probably not,

So instead, let’s try removing the loop and designing the workflow without it, since n8n already loops through items by design,

Here is what the workflow looks like without loops:

hi @djjace I believe the wf json you shared and that I ran is not exactly the one you’re using because in my wf execution it goes to the node “insert rows“ and output 30 items :

But on your case it goes into the node “If1“ and outputs 10 items :

Can you pls provide this latest wf json you’re using ?