# Why can't I get variable batching for my Loop?

**URL:** <https://community.n8n.io/t/why-cant-i-get-variable-batching-for-my-loop/95372>\
**Category:** Questions\
**Tags:** splitinbatches, loop-over-items\
**Created:** [April 1, 2025, 5:47am UTC](https://community.n8n.io/t/why-cant-i-get-variable-batching-for-my-loop/95372 "2025-04-01T05:47:47Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Will\_Roske](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/will_roske/32/65960_2.png) [@Will\_Roske](https://community.n8n.io/u/Will_Roske)\
**Post date:** [April 1, 2025, 5:47am UTC](https://community.n8n.io/t/why-cant-i-get-variable-batching-for-my-loop/95372/1 "2025-04-01T05:47:47Z")

</div>

Hello,

So I need to send images to ChatGPT for analysis. Each item has a different number of images, so I have a segment that figures out how many images there are of every item. The problem is that my Loop Over Items node doesn’t loop when I use the variable batch size. When I use a static batch size, it works perfectly. What can I do so that my loop works and takes the specific number of images?

 ![image](https://europe1.discourse-cdn.com/n8n/original/3X/0/2/02480aa60d0ad322785eac11494cca09ed2088d2.png)  
 ![image](https://europe1.discourse-cdn.com/n8n/original/3X/2/a/2a1205f35d5e77a8fc941103932a9e21ab1501e8.png)  
 ![image](https://europe1.discourse-cdn.com/n8n/original/3X/4/e/4e6f802906f38a83ac45d610cb706c76bc942724.png)

All the code node does is combine all of the images so that they can be uploaded to Chat.

Thank you all for your time!

---

<div class="post-metadata">

**Author:** ![Olek](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/olek/32/59619_2.png) [@Olek](https://community.n8n.io/u/Olek)\
**Post date:** [April 1, 2025, 8:25am UTC](https://community.n8n.io/t/why-cant-i-get-variable-batching-for-my-loop/95372/2 "2025-04-01T08:25:21Z")

</div>

There are nodes to reduce the number of items if needed and aggregate them. But the strategy depends on the data structure at hand.

Could you post your workflow with some data pinned in it?  
See how: [OleksiyRudenko’s gists · GitHub](https://gist.github.com/OleksiyRudenko#post-an-interactive-copy-of-your-workflow)

---

<div class="post-metadata">

**Author:** ![Franz](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/franz/32/66008_2.png) [@Franz](https://community.n8n.io/u/Franz)\
**Post date:** [April 1, 2025, 8:41am UTC](https://community.n8n.io/t/why-cant-i-get-variable-batching-for-my-loop/95372/3 "2025-04-01T08:41:59Z")

</div>

![image](https://europe1.discourse-cdn.com/n8n/original/3X/9/a/9a90287121b84ae88108f31b1ae7a63946902184.png)

The Loop node with a dynamic batch size works pretty well — but not exactly as expected. The batch size is updated in each loop cycle based on the result of the last node in the loop.

That’s not what you actually want.

I also noticed that your loop has two inputs (two paths going in). But the loop doesn’t automatically merge those inputs. Instead, it will first loop through the items from the first input, and only after that move on to the items from the second input.

To fix this, you can use something like a **Merge** node before the loop.

Code is easier to understand than words — so here’s an example to show you what I mean.  
The first two code nodes are just used to generate some sample data.

---

<div class="post-metadata">

**Author:** ![Will\_Roske](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/will_roske/32/65960_2.png) [@Will\_Roske](https://community.n8n.io/u/Will_Roske)\
**Post date:** [April 1, 2025, 4:19pm UTC](https://community.n8n.io/t/why-cant-i-get-variable-batching-for-my-loop/95372/5 "2025-04-01T16:19:05Z")

</div>

Ok, after reading your response again. I duplicated the google sheets read node and put it in the loop, and it almost works, but it takes the first variable again instead of moving on to the second variable. Any Ideas?

Thank You very much for the help already though!

---

<div class="post-metadata">

**Author:** ![Olek](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/olek/32/59619_2.png) [@Olek](https://community.n8n.io/u/Olek)\
**Post date:** [April 1, 2025, 4:25pm UTC](https://community.n8n.io/t/why-cant-i-get-variable-batching-for-my-loop/95372/6 "2025-04-01T16:25:56Z")

</div>

Show some code. There can be a lot of reasons. E.g. referring data using `$(nodeNaame).first()`. Actual workflow posted will help to avoid guesswork.

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/system/32/195824_2.png) [@system](https://community.n8n.io/u/system)\
**Post date:** [June 30, 2025, 4:26pm UTC](https://community.n8n.io/t/why-cant-i-get-variable-batching-for-my-loop/95372/7 "2025-06-30T16:26:07Z")

</div>

Closed on June 30, 2025, 4:26pm UTC

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