# Loops in node red

**URL:** https://discourse.nodered.org/t/loops-in-node-red/11235
**Category:** General
**Created:** [17 May 2019 10:39 UTC](https://discourse.nodered.org/t/loops-in-node-red/11235 "2019-05-17T10:39:33Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![rjdugar](https://avatars.discourse-cdn.com/v4/letter/r/e79b87/32.png) [@rjdugar](https://discourse.nodered.org/u/rjdugar)
#### Post date: [17 May 2019 10:39 UTC](https://discourse.nodered.org/t/loops-in-node-red/11235/1 "2019-05-17T10:39:33Z")

</div>

Hello Everyone ,

I am new to node-red  
I am trying to create a flow in which i have to loop for condition and within loop i need to add sub flows based on value of loop .  
ex --  
index value -- sce1 then subflow sc1 likewise .

Any help willl be great .

thnks/

---

<div class="post-metadata">

### Author: ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)
#### Post date: [17 May 2019 10:42 UTC](https://discourse.nodered.org/t/loops-in-node-red/11235/2 "2019-05-17T10:42:45Z")

</div>

Welcome @rjdugar

Do you mean you want each each iteration of the loop to call a different subflow instance?

One way would be to have a counter property on the message that you increment each time you loop, and then use a Switch node to route the message to the appropriate subflow instance node based on the counters value.

Does that make sense?

(btw, have moved to the #general category as #development is for development of Node-RED itself, not general usage questions)

---

<div class="post-metadata">

### Author: ![rjdugar](https://avatars.discourse-cdn.com/v4/letter/r/e79b87/32.png) [@rjdugar](https://discourse.nodered.org/u/rjdugar)
#### Post date: [17 May 2019 11:55 UTC](https://discourse.nodered.org/t/loops-in-node-red/11235/3 "2019-05-17T11:55:55Z")

</div>

thanks will note tht .
