web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Comparing two arrays u...
Power Automate
Unanswered

Comparing two arrays using Select

(1) ShareShare
ReportReport
Posted on by 894
Array with extra items:
[{
"ID": "123"
},
{
"ID": "454"
},
{
"ID": "613"
},
{
"ID": "981"
}]
 
Array with lesser items
[{
"ID": "123"
},
{
"ID": "613"
},
{
"ID": "981"
}]
 
Find the extra items in List one, it can be more than one.
 
I have tried to follow @abm great solution https://www.youtube.com/watch?v=SFlj1ykpvgM
 
I find @abm 's solution to be easiest but the compared values never compares as true, all as false, because the lists differ. Is there a way to modify it?
 
Here is how I have implemented the solution: 
Skärmavbild 2022-03-21 kl. 12.40.59.png

The array with lesser items has 38 items and the total in Extra items is 40 instead of becoming an array with 2 items, it takes all the 40 items. So something with the comparing isn't working. Or am i comparing the wrong array in the above picture?

Categories:
I have the same question (0)
  • abm abm Profile Picture
    32,865 Most Valuable Professional on at

    Hi @shavora 

     

    Could you please post a screenshot of your flow? Just a quick thought is convert both sides of the values to string() as well.

     

    Thanks

  • Gyllentid Profile Picture
    894 on at

    @abm that's a good idea. These are the id string for dataverse tables so they are like this: "3714c30a-fd65-4a42-8b3e-4fd2c664dbb6"

     

    Skärmavbild 2022-03-21 kl. 13.29.51.png

    Skärmavbild 2022-03-21 kl. 13.30.04.png

    It might work with parse json on both arrays, comparing the body and contains with the current item. Going to try...

  • KvB1 Profile Picture
    1,596 on at

    Whats the goal of comparing them? You want to know which items are in array 1 but not in array 2?

  • Gyllentid Profile Picture
    894 on at

    @KvB1 Hi 🙂 

    I need to know which one is missing so that I can assign the right status to it. When we delete a booking for a person, we need that person to get the status available. When you delete a row in Dataverse only the id of that row is saved, none of the field values or related values are saved. This is a workaround to assign the right status "booked" or available" for candidates going an onboarding training.

    Good to know is that Candidates is listed in one table, Bookings in one table and Course slots in one table. Booking table is having a lookup to each of the other two. 

  • KvB1 Profile Picture
    1,596 on at

    Okay, sounds like you could use a simplified version of Pieters method:

     

    To get an array of all records that exist in both tables:

    Use intersection(variables('BigArray'),variables('SmallArray')) and store it in a variable, lets call it CommonRecords

     

    Then use a filter array action, where you filter the big array, and as the filter condition use:

    contains(variables('CommonRecords'),item())       is equal to      false

     

    The output of this will be an array which holds all the records from the big array which are not present in the small array

  • Gyllentid Profile Picture
    894 on at

    @KvB1 Thanks for the idea. After trying to Parse Json on @abm 's idea I managed to get that to work.

  • GI-04112040-0 Profile Picture
    on at

    Going through this right now with an array of group members vs items in a sharepoint list... No matter how I write it, my condition never picks up that the group member already exists in the list and runs my flow against every member in the group. Which is problematic because the flow is written to create a list item for group members that don't already exist...

  • Matthy79 Profile Picture
    4,180 Super User 2024 Season 1 on at

    This should work too.

     

    Matthy79_0-1678651984378.png

     

  • sahrastolz Profile Picture
    30 on at

    Loved this solution. Thanks for sharing it!

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 501 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 323 Moderator

#3
abm abm Profile Picture

abm abm 237 Most Valuable Professional

Last 30 days Overall leaderboard