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
Power Automate News & Announcements

Power Automate News & Announcements

Keep up to date with current events and community announcements in the Power Automate community.

Power Automate Community Blog

Power Automate Community Blog

Check out the latest Community Blog from the community!

Top Solution Authors
Users online (5,652)