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

Compare two object arrays by specific key and save non-duplicates

I've created two object arrays. I would like to compare the two array items by 'SpaceId' key, then add whatever items don't match to a third array. Here is a sample of my two arrays:

Screen Shot 2021-04-26 at 3.25.00 PM.pngScreen Shot 2021-04-26 at 3.25.07 PM.png

 

I would like my condition to be if variable(array1)['SpaceId'] is not equal to variable(array2)['SpaceId'] then append to a 3rd array.

If they are equal then do nothing.

 

I'm pretty sure my syntax is probably totally off but I hope I'm getting my goal across. I'm new to the game so I would appreciate any help that I can get with this.

 

1 ACCEPTED SOLUTION

Accepted Solutions
PrasadAthalye
Community Champion
Community Champion

Here is how you can do it...

 

PrasadAthalye_0-1619479850760.png

 

Compose2 Expression --> item()?['spaceid']

 

Filerarray expression --> item()?['spaceid']

 

Check Length expression -->length( body('Filter_array'))

 

Finally append to array expression --> body('Filter_array')[0]

 

Please Like and Mark this as Answer if it resolves your Issue.

Power Automate Community

View solution in original post

4 REPLIES 4
PrasadAthalye
Community Champion
Community Champion

Here is how you can do it...

 

PrasadAthalye_0-1619479850760.png

 

Compose2 Expression --> item()?['spaceid']

 

Filerarray expression --> item()?['spaceid']

 

Check Length expression -->length( body('Filter_array'))

 

Finally append to array expression --> body('Filter_array')[0]

 

Please Like and Mark this as Answer if it resolves your Issue.

Power Automate Community

@dgonzalesjr - Did you get chance to check my solution?

Please Like and Mark this as Answer if it resolves your Issue.

Power Automate Community
PrasadAthalye
Community Champion
Community Champion

@dgonzalesjr - Did you get chance to check my solution?

Please Like and Mark this as Answer if it resolves your Issue.

Power Automate Community
dgonzalesjr
Regular Visitor

Hello @PrasadAthalye so sorry for the wait. This solution has worked for me. Thank you so much for your help!

Helpful resources

Announcements
 WHAT’S NEXT AT MICROSOFT IGNITE 2022

WHAT’S NEXT AT MICROSOFT IGNITE 2022

Explore the latest innovations, learn from product experts and partners, level up your skillset, and create connections from around the world.

Register for a Free Workshop.png

Register for a Free Workshop

Learn to digitize and optimize business processes and connect all your applications to share data in real time.

September Events 2022

Check out all of these events

Attend in person or online, there are incredible conferences and events happening all throughout the month of September.

Users online (3,429)