Skip to main content

Notifications

Power Automate - General Discussion
Unanswered

Joining/Merging Arrays

(0) ShareShare
ReportReport
Posted on by 55

Hello!

I have two SharePoints that I am trying to Join/Merge in PowerAutomate: SP1 1 with the full list of vehicles & SP 2 with inspection times. Both share the same data in "Title." The inspections SP has a column called "Time"

 

Currently I have:

Get Items (gets items from SP1)

Get Items 2 (gets items from SP2)

Select (called Select-Inspection-Times)

  • From = 

 

Outputs('Get_Items_2')?['body/value']​

 

  • Map = 

 

concat('"',item()?['Title'],'":',item())​

 

Compose

  • Inputs = 

 

json(concat('{',join(body('Select-Inspection-Times'),','),'}'))​

 

Select

  • From = 

 

Outputs('Get_Items')?['body/value']​

 

  • Map =
    • Vehicle = 

 

item()?['Title']​

 

  • Inspection Time = 

 

outputs('Compose')?[string(item()?['Title'])]?['Time']​

 

Currently, I am getting the correct data, but only the first iteration. So if I have in SP1:

  • A
  • B
  • C

and in SP 2:

  • A - 9:00
  • A - 10:00
  • B - 8:00

When I run the flow I get:

 

[
 {
 "Vehicle": "A",
 "Inspection Time": "9:00"
 },
 {
 "Vehicle": "B",
 "Inspection Time": "8:00"
 },
 {
 "Vehicle": "C",
 "Inspection Time": null
 }
] 

 

I am hoping to be able to get something that looks like: 

 

[
 {
 "Vehicle": "A",
 "Inspection Time": "9:00, 10:00"
 },
 {
 "Vehicle": "B",
 "Inspection Time": "8:00"
 },
 {
 "Vehicle": "C",
 "Inspection Time": null
 }
] 

 

Any suggestions on what I need to do to get there? I feel like I'm close, but I can't get it to run with more than 1 iteration of each. 

Thanks!

  • Nived_Nambiar Profile Picture
    Nived_Nambiar 17,039 on at
    Re: Joining/Merging Arrays

    Hi @dsopshin 

     

    Your current code seems to taking first Inspection time entry, let's make the flow design little bit simpler

     

    Consider this is the vehicle list

    Nived_Nambiar_0-1716749270846.png

     

    Consider this as inspection list

    Nived_Nambiar_1-1716749309925.png

     

     

    Now let's go to flow design

     

    1. Get items from vehicle list

    Nived_Nambiar_2-1716749349688.png

     

    2. Select only Title column from the vehicle list using select action

    Nived_Nambiar_3-1716749417823.png

     

    3. get items from Inspection list

    Nived_Nambiar_4-1716749443288.png

     

    4. Select the title and Inspection Time column values from output of Get items of Inspection List

    Nived_Nambiar_5-1716749509028.png

     

    5. Use compose action to create an array structure like below

    Nived_Nambiar_6-1716749550068.png

     

     

    6. use select action to map each vehicle to its inspection timings (as required per output)

    Nived_Nambiar_7-1716749626466.png

     

    Nived_Nambiar_8-1716749645497.png

     

    Nived_Nambiar_11-1716749823988.png

     

     

    Expression - 

    if(empty(join(xpath(xml(outputs('Compose')),concat('//data[Title="',item(),'"]/InspectionTime/text()')),',')),null,join(xpath(xml(outputs('Compose')),concat('//data[Title="',item(),'"]/InspectionTime/text()')),','))
     
    Now see the result-
     

    Nived_Nambiar_12-1716749876326.png

     

     

    Hope it helps !

    Thanks & Regards,

    Nived N 🚀

    LinkedIn: Nived N's LinkedIn
    YouTube: Nived N's YouTube Channel
    Blog: Nived Nambiar's Blogs

    🔍 Found my answer helpful? Please consider marking it as the solution!
    Your appreciation keeps me motivated. Thank you! 🙌

     

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

Microsoft Kickstarter Events…

Register for Microsoft Kickstarter Events…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Announcing Forum Attachment Improvements!

We're excited to announce that attachments for replies in forums and improved…

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 145,445

#2
RandyHayes Profile Picture

RandyHayes 76,287

#3
Pstork1 Profile Picture

Pstork1 64,741

Leaderboard