Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Automate - Building Flows
Answered

Joining 2 arrays based on position and not a common ID

(0) ShareShare
ReportReport
Posted on by 4

I have exhausted looking for an answer so I am going to ask.

 

I have 2 arrays and I need to join them so that I can then have my table created from a single array and send it out. Here are the arrays:

Array1

Names from a name picker

 

{
 "Resource Name": "First Last"
}

 

2nd Array has a number that is a string input on the front end form but I convert to an array so it looks like this

{
"percent": "100"
}

 

The first array might have 1 or 20 names in it and the 2nd array will have the same number of items as the first array. I need to add the 2nd array to the first as a property so that it comes out like this:

 

[
 {
 "Resource Name": "First Last",
 "Percent Allocated": "100"
 },
 {
 "Resource Name": "First Last",
 "Percent Allocated": "50"
 }
]

 

 

 

How do I merge the arrays based on position of the items, for instance the 2nd array [0] goes to the first array [0] as a property and so on throughout the total number of items?

 

Thank you in advance!

Mokono

  • Mokono Profile Picture
    4 on at
    Re: Joining 2 arrays based on position and not a common ID

    In the append to array box, what is the expression you are using to pull in each of the different array items as it is cutoff in the screenshot.

  • eliotcole Profile Picture
    4,228 Super User 2025 Season 1 on at
    Re: Joining 2 arrays based on position and not a common ID

    Hi, @Mokono, there's quite a few answers here that might've helped you, but it can be done in a single step with a bit of creative expression writing!

     

    Range That Is The Length Of Your Array Then Pick

    So ... a quick and easy way to do this is to take the two arrays and then select them into one array, using a range() expression in its From field.

     

    In my example, below, you will see that I am referencing my two 'mock' variables, here, but yours will be different references ... just change variables('arrayOneVAR') / variables('arrayTwoVAR') to point to your arrays:

    merge-arrays-DELETABLE.jpg
    From
    range(
    	0, 
    	length(
    		variables('arrayOneVAR')
    	)
    )
    Map
    Key Value
    Resource Name
    variables('arrayOneVAR')[item()]?['Resource Name']
    Percentage
    variables('arrayTwoVAR')[item()]?['percentage']

    What this does is:

    1. Makes a range(), which is an array of numbers from the number before the comma, to the number afterwards.

      Here, that second number is the amount of items in the array containing the Resource Name items.

      This looks like this in my above example:
      [
      	0,
      	1,
      	2
      ]
    2. For each item in that range it then makes the appropriate Key/Value pairs.

      Here you are using the item() (which is simply a number) to select an entry from the previous array.

      So the first entry here is 0 that will select the Resource Name from entry 0 of arrayOneVAR:
      variables('arrayOneVAR')[item(0)]?['Resource Name']

     

    Hope this helps!

  • Verified answer
    ScottShearer Profile Picture
    25,228 Most Valuable Professional on at
    Re: Joining 2 arrays based on position and not a common ID

    @Mokono 

    Here is one solution:

    image.pngimage.pngimage.png

    The end result looks like this (partial screen shot):

    image.png

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

Michael Gernaey – Community Spotlight

We are honored to recognize Michael Gernaey as our June 2025 Community…

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 566 Super User 2025 Season 1

#2
David_MA Profile Picture

David_MA 516 Super User 2025 Season 1

#3
stampcoin Profile Picture

stampcoin 492