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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Loop through an array ...
Power Automate
Answered

Loop through an array by a value in another array to create a different array

(0) ShareShare
ReportReport
Posted on by 727 Super User 2025 Season 2
Hello -
 
I've tried different 'apply to each' scenarios without luck for the following.
 
I want to loop through array 1 by zone using value zone number in array 2 and create array 3.
 
Array 1
[
{
"Zone": "1",
"LookUpStr": "25"
},
{
"Zone": "2",
"LookUpStr": "35"
},
{
"Zone": "3",
"LookUpStr": "80"
},
{
"Zone": "4",
"LookUpStr": "45"
},
{
"Zone": "5",
"LookUpStr": "157"
}
]
 
Array 2
[
{
"Zone Number": 2
},
{
"Zone Number": 3
},
{
"Zone Number": 4
}
]
 
Array 3 created by flow
[
{
"LookUpStr": "35",
"LookUpStr": "80",
"LookUpStr": "45"
}
]
 
Appreciate any suggestion.
Thanks!
Categories:
I have the same question (0)
  • Verified answer
    Nived_Nambiar Profile Picture
    18,129 Super User 2025 Season 2 on at
     
    Try this approach without using loop :)
     
    1. use 2 initialize variables to initialize array 1 and array 2 as shown below
     
     
     
    2. use compose action to format the Array 2 as shown below
     
     
    3. Use filter array to get required values
    Expression: 
    xpath(xml(outputs('Format_Array2')),concat('//Zone_x0020_Number/text()=','''',item()?['Zone'],''''))
     
    4. use select action to select LookUpStr property from output of filter array
     
    see the output of select action 
     

    Thanks & Regards,
    Nived N

    Stay connected:
    LinkedIn | YouTube | Blogs

    Was this answer helpful?
    If yes, please mark it as the solution by selecting the checkbox in the discussion thread.
    Your feedback motivates me to keep contributing. Thank you!

  • Cgangweg01 Profile Picture
    727 Super User 2025 Season 2 on at
    Thank you! @Nived_Nambiar 
     
    That worked! I was even able to use the output in an apply to each to make an API call per LookUpStr number. Awesome! Now I need to figure out how to compile each API call result into a single array for further filtering.
     
    Also wondering ... could you explain what the xpath expression is actually doing?
     
    xpath(xml(outputs('Format_Array2')),concat('//Zone_x0020_Number/text()=','''',item()?['Zone'],''''))
     
    Thanks Again!

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 519 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 296 Moderator

#3
abm abm Profile Picture

abm abm 232 Most Valuable Professional

Last 30 days Overall leaderboard