cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Regular Visitor

Join in Compose does not work with Nested loops.

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

1 ACCEPTED SOLUTION

Accepted Solutions
Community Support
Community Support

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

 

 

 

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
Community Support
Community Support

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

 

 

 

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

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

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

Power Platform ISV Studio

Power Platform ISV Studio

ISV Studio is designed to become the go-to Power Platform destination for ISV’s to monitor & manage published applications.

Users online (12,117)