cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Turulense2020
New Member

Combine specific fields from array variable

Dear community,

 

I am building a new flow and I encountered this problem.

 

I have an array variable with 'n' items (for the sake of simplification, I show an example with only 2 items). I would like to create an array with only one item, combining the fields/properties of the arrays as follows:

"Name": "Name1", "Name2", ...

"City": "City1"

"Colour": "Color1"

"Music": "Music1"

"Language": "Language 1", "Language2", ...

 

Example:

 

[

  {

    "Name": "Michael",

    "City": "Brighton",

    "Colour": "Green",

    "Music": "Rock",

    "Language": "Spanish"

  },

  {

    "Name": "Peter",

    "City": "Brighton",

    "Color": "Green",

    "Music": "Rock",

    "Language": "English"

  }

]

 

Expected result:

 

[

  {

    "Name": "Michael","Peter",

    "City": "Brighton",

    "Colour": "Green",

    "Music": "Rock",

    "Language": "Spanish","English"

  }

]

 

I have tried with union(), join() and first() unsuccessfully.

 

Thank you!

1 ACCEPTED SOLUTION

Accepted Solutions
v-yiwenxie-msft
Microsoft
Microsoft

Hi @Turulense2020 

 

I’ve built a flow and have tested it successfully which can apply to ‘n’ items (though there are only two items in my flow).

 

I’ve used your example in ‘Compose’:

2.26-1.PNG

 

And the outputs of my flow is:

2.26-2.PNG

 

The whole flow is as below:

2.26-3.PNG

 

The detailed steps for ‘initialize variable’:

2.26-4.PNG

 

The detailed steps for ‘Apply to each’:

2.26-5.PNG

The function used:

items('Apply_to_each')?['Name']

items('Apply_to_each')?['Language']

 

The detailed step for ‘Select’:

2.26-6.PNG

The functions used:

item()?['City']

item()?['Colour']

item()?['Music']

 

For more info about the functions items(), item():

Reference guide for functions in expressions - Azure Logic Apps | Microsoft Docs

Reference guide for functions in expressions - Azure Logic Apps | Microsoft Docs

 

If you still have any problem, please feel free to let me know.

 

Best Regards,
Community Support Team _ Kira Xie
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

1 REPLY 1
v-yiwenxie-msft
Microsoft
Microsoft

Hi @Turulense2020 

 

I’ve built a flow and have tested it successfully which can apply to ‘n’ items (though there are only two items in my flow).

 

I’ve used your example in ‘Compose’:

2.26-1.PNG

 

And the outputs of my flow is:

2.26-2.PNG

 

The whole flow is as below:

2.26-3.PNG

 

The detailed steps for ‘initialize variable’:

2.26-4.PNG

 

The detailed steps for ‘Apply to each’:

2.26-5.PNG

The function used:

items('Apply_to_each')?['Name']

items('Apply_to_each')?['Language']

 

The detailed step for ‘Select’:

2.26-6.PNG

The functions used:

item()?['City']

item()?['Colour']

item()?['Music']

 

For more info about the functions items(), item():

Reference guide for functions in expressions - Azure Logic Apps | Microsoft Docs

Reference guide for functions in expressions - Azure Logic Apps | Microsoft Docs

 

If you still have any problem, please feel free to let me know.

 

Best Regards,
Community Support Team _ Kira Xie
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

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

Users online (1,830)