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 Automate
Answered

Filtering two Arrays

(0) ShareShare
ReportReport
Posted on by 122

Hi Community! I am sure there is something little I am missing but the logic makes no sense on the results to me!

 

I have two arrays, I want to get all items that appear in Array A and not in Array B, I use a filter array and it only produces everything in Array A, even if it appears in Array B. Flow below;

SamMartin_1-1706266785583.png

 

SamMartin_0-1706266770316.png

Thanks in advance 🙂

Categories:
I have the same question (0)
  • Verified answer
    ManishSolanki Profile Picture
    15,091 Super User 2025 Season 2 on at

    Hi @SamMartin 

     

    You need to write an expression to compare each element of Array A. Pls use expression on the life side of the condition as shown below:

    ManishSolanki_0-1706268693367.png

    Expression needs to be entered in the expression box as highlighted in the above screenshot:

    item()

     

     

    If this helps & solves your problem, please remember to give a 👍 and accept my solution as it will help others in the future.

     

  • SamMartin Profile Picture
    122 on at

    Hi @ManishSolanki 🙂

    How would I go about comparing it to each value in Array B? Use an Apply for Each? I get the same issue at the end when using current item to compare, it just produces everything in one array rather than everything that isn't in the other array?

  • SamMartin Profile Picture
    122 on at

    Ignore that^ It works with just using item(), I knew it would be simple! Thanks 🙂

  • SamMartin Profile Picture
    122 on at

    @ManishSolanki Sorry to be a pain, I used this on a test flow and it worked fine. I have replicated it by just simply replacing the variables with the ones in my actual flow however I am getting a lot of values in the outputs that exists in both A & B array, I am not sure why? 

    SamMartin_0-1706278545066.png

    Screenshot 2024-01-26 141329.png

    The Black values were handeled correctly, however the green values (in the inputs) should not be in the outputs as they exist in both, not just one array. The compose outputs is simply used as I use a compose to union one of the arrays to remove duplicates.

  • SamMartin Profile Picture
    122 on at

    I have tried replacing all of the variables and tried swapping around the item() and outputs and still no luck, it won't produce a consistent result of items in Array A but not in Array B

  • Verified answer
    eliotcole Profile Picture
    4,363 Moderator on at

    Hi, @SamMartin, I believe that as long as your arrays are 'simple' string arrays as you have indicated above then all you need to do is change the condition in your Filter array action to have the "List of Sharepoint" on the left and the following pasted into the right:

    @{item()}

    That should look something like this:

    flow.png

     

    From that I got these results:

    result.png

     

    If you have trouble getting the item() in there, instead tap in the right side and go to the expression editor, and just type in the following and bosh it in:

    item()

     

  • SamMartin Profile Picture
    122 on at

    After doing some looking, there were slight differences in the duplicating values in the arrays, capitals spaces at the start etc... Added some validation to make everything the same case and trim the values, works as expected! Thanks for the help 🙂

  • eliotcole Profile Picture
    4,363 Moderator on at

    Yeah, so what I tend to do there is to use judicious usage of trim() and either toLower() or toUpper() on both values.

     

    Like toLower(trim(VALUE)) ... that's more difficult when you're doing an array contains kind of thing, mind.

     

    Either way, really glad that you got there, @SamMartin !

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