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 Platform Community / Forums / Power Automate / Join in Compose does n...
Power Automate
Answered

Join in Compose does not work with Nested loops.

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

Hi,

 

We want to create a flow which sends automated reports for all our features.

We have a DB, where we store information with report name and sub features.

 

First, we loop on all the reports.

Then, we loop on all the sub-features and create a dynamic query in Kusto. Dynamic query is being created by use of Join.

We run the query and send the mail containing graphs of usage.

This runs fine if we run only for one hard coded report. Dynamic query is correctly created and mail is send successfully.

 

If we try to run this for all the reports, join has to happen in inner for loop. And this type of flow fails to be saved. What is the work around for this? Do we have way to concatenate strings in inner for loop, which can be used in outer for loop?

 

Please refer to this flow. This works fine. But if we try to give GetAllReportTitles under loop, join starts crying.

 

Flow_Join_NestedLoop.PNG

Categories:
  • Verified answer
    v-xida-msft Profile Picture
    Microsoft Employee on at

    Hi @gunjansa,

     

    Could you please share a bit more about the strings that you need to concatenate within your "Apply to each" action?

     

    If you want to concatenate strings within the "Apply to each" action, you should initialize a String variable firstly to store the concatenated string (which could be used in outer for loop). I have made a test on my side, please consider reference the following workaround:

    • Add a proper trigger, here I use Flow Button trigger.
    • Add a Variables-> "Initialize variable" action, Name set to OriginalArray, Type set to Array and Value set to following formula:
    [
     "Apple",
     "Balana",
     "Pear",
     "Orange"
    ]
    • Add a Variables-> "Initialize variable 2" action, Name set to FinalString, Type set to String and Value set to empty.
    • Add a "Apply to each" action, input parameter set to OriginalArray variable.
    • Within "Apply to each", add a "Compose" action, Inputs set to following formula: 
    concat(item(),'&',variables('FinalString'))

    Note: item() funciton is used to obtain each loop value.

     

    Add a "Set variable" action, Name choose FinalString and Value set to output of "Compose" action.

     

    • Under "Apply to each", add a "Compose 2" action, Inputs set to FinalString variable.

    Image reference:19.JPG

     

    20.JPG

    The flow works successfully as below:21.JPG

     

    Best regards,

    Kris

     

     

     

  • gunjansa Profile Picture
    Microsoft Employee on at

    Thanks a lot Support Team. This is super helpful. Worked seamlessly 🙂

  • beyondthebox Profile Picture
    28 on at

    Actually the issue in the title was not resolved regardless of what was displayed in the solution. While you can nest Apply-To-Each loops, you cannot refer to an action inside a loop if it is contained in another loop (often done when merging data from loops). While the flow will accept your expressions, a save will fail.

     

    HUGE ISSUE that has not been corrected in 5 years!

     

     

     

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

Leaderboard > Power Automate

#1
Mohsin Ali Profile Picture

Mohsin Ali 330

#2
11manish Profile Picture

11manish 282 Super User 2026 Season 2

#3
Henil Profile Picture

Henil 123

Last 30 days Overall leaderboard