Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Automate - Building Flows
Unanswered

Comparing two arrays using Select

(1) ShareShare
ReportReport
Posted on by 892
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?

  • sahrastolz Profile Picture
    30 on at
    Re: Comparing two arrays using Select

    Loved this solution. Thanks for sharing it!

  • Matthy79 Profile Picture
    4,178 Super User 2024 Season 1 on at
    Re: Comparing two arrays using Select

    This should work too.

     

    Matthy79_0-1678651984378.png

     

  • GI-04112040-0 Profile Picture
    on at
    Re: Comparing two arrays using Select

    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...

  • Gyllentid Profile Picture
    892 on at
    Re: Comparing two arrays using Select

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

  • KvB1 Profile Picture
    1,596 on at
    Re: Comparing two arrays using Select

    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
    892 on at
    Re: Comparing two arrays using Select

    @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
    Re: Comparing two arrays using Select

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

  • Gyllentid Profile Picture
    892 on at
    Re: Comparing two arrays using Select

    @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...

  • abm abm Profile Picture
    32,472 Most Valuable Professional on at
    Re: Comparing two arrays using Select

    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

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

Michael Gernaey – Community Spotlight

We are honored to recognize Michael Gernaey as our June 2025 Community…

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

Leaderboard >