web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Automate
Answered

Nested For Each Loop

(0) ShareShare
ReportReport
Posted on by 39

Hello,

 

I'm currently working on implementing a nested "for each" loop in my project. I have two lists that will store invoicing text and invoicing amounts, each containing up to 10 entries. My goal is to iterate through these lists and utilize the stored variables within our third-party software, combining each text entry with its corresponding amount (e.g., Text1 + Amount1, Text2 + Amount2, and so on).

 

However, I've encountered an issue with my current approach. It doesn't iterate correctly; instead, it begins with the first text entry and then loops through all the amounts before moving on to the next text entry and repeating the process for all amounts, and so forth.

 

Thanks for your assistance

 

Brg

 

Screenshot 2023-09-05 140100.png

I have the same question (0)
  • Srini007 Profile Picture
    3,490 Super User 2026 Season 1 on at

    Hi @Cryzle 

     

    Here is the steps for creating the workflow

     

    1) As you have two lists let's say first list is alphabetList and second is NumberList

    2) Now use Set Variable and write the variable name as LoopIndex and value is 0

    3) Use For Each action and the list is alphabetList

    4) Now Inside the ForEach you can put DisplayMessage(For Demo) and write as %CurrentItem% + %NumberList[LoopIndex]%

    5) use Increase Variable action inside the loop and set the value as 1

     

    below is the screenshot of the flow for your reference

     

    Srini84_0-1693921531603.png

    Cautious that you have the same number of elements in the both lists, else it will through the error

     

    If you find this reply helpful, please consider giving it a LIKE AND

    If this reply answers your question or solves your issue, please ACCEPT AS SOLUTION

     

    Thanks,

    Srini

     

  • Verified answer
    Agnius Bartninkas Profile Picture
    Most Valuable Professional on at

    @Srini007 's solution will do the trick, but when indexes are needed, I would suggest using a normal Loop action, instead of a For each. You would then not need to add an action to increment your index variable, as the Loop action does that for you.

     

    Use a Loop starting at 0, ending at %Rechnungstextlist.Count-1%, and incrementing a %LoopIndex% variable by 1. Then you can get the text as %Rechnungstextlist[LoopIndex]% and the amount as %Verkäufelist[LoopIndex]%.

     

    This will make your flow cleaner, with less actions, and easier to read. But what Srini suggested will also work.

    -------------------------------------------------------------------------

    If I have answered your question, please mark it as the preferred solution. If you like my response, please give it a Thumbs Up.

     

    I also provide paid consultancy and development services using Power Automate. If you're interested, DM me and we can discuss it.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
David_MA Profile Picture

David_MA 252 Super User 2026 Season 1

#2
11manish Profile Picture

11manish 169

#3
Haque Profile Picture

Haque 154

Last 30 days Overall leaderboard