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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Check if item from col...
Power Apps
Answered

Check if item from collection1 exist in collection 2

(0) ShareShare
ReportReport
Posted on by 11

Hi together,

 

I hope someone could help me with my problem:

I have two collections with some fields. Now i want to check if items in collection 1 exist in collection 2 (like a double foreach). So i want to check im ItemsFromCollection1.Title = ItemsFromCollection2.Title and if yes add the whole item from Collection1 and add a new column and fill it with the value true (string).

 

I started with something like that (but it dont work):

 

ClearCollect(Collection3; ForAll(Collection1;ForAll(Collection2;If(Collection1Title.Value in Collection2Title; AddColumns(MySharePointList; "colMatch";"True")))));;

 

I hope anyone could help me

Greetings

Daniel

Categories:
I have the same question (0)
  • Verified answer
    Cooper01 Profile Picture
    664 on at

    Not exactly sure what the initial collections look like so here are the ones I initialized to show how you could get the duplicate titles. If I'm understanding you correctly, the final collection would have the two records where title is Red & Green as those titles appear in both collections.

    Collection 1

    ClearCollect(ItemsFromCollection1, {Title: "Red", Quantity: 2}, {Title: "Green", Quantity: 1}, {Title: "Blue", Quantity: 6})

    Collection 2

    ClearCollect(ItemsFromCollection2, {Title: "Red", Quantity: 8}, {Title: "Green", Quantity: 1})

    Collection 3

    Clear(Collection3);
    ForAll(
     ItemsFromCollection1,
     If(
     ThisRecord.Title in ItemsFromCollection2.Title,
     Collect(
     Collection3,
     {
     Record: ThisRecord,
     inBoth: true
     }
     )
     )
    );

     

     

  • FabianAckeret Profile Picture
    969 on at

    Hi @DanielPowerUser 

    In addition to @Cooper01 's response:

    If you would like to add the value for the inBoth column to false in case it's not in both columns, you just need to complete the If() with the false parameter, like so:

    ForAll(
     ItemsFromCollection1,
     If(ThisRecord.Title in ItemsFromCollection2.Title,
     Collect(colMatch,{Record: ThisRecord,inBoth: false}),
     Collect(colMatch,{Record: ThisRecord,inBoth: true})
     )
    )

     

    Furthermore, if you'd like to have a new collection that only has some coluimns, including the inBoth and they should all be next to each other rather than as a table in a collection, you could use this:

    ForAll(
     ItemsFromCollection1,
     If(ThisRecord.Title in ItemsFromCollection2.Title,
     Collect(colMatch,{Record: ThisRecord.Title,inBoth: false}),
     Collect(colMatch,{Record: ThisRecord.Title,inBoth: true})
     )
    )

     

    Kind regards,

    Fabian

     

  • DanielPowerUser Profile Picture
    11 on at

    Hi @Cooper01,

    this is excatly what i have looked for. A big Thank you for your fast help!

    Kind regards
    Daniel

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 549 Most Valuable Professional

#2
Kalathiya Profile Picture

Kalathiya 225 Super User 2026 Season 1

#3
Haque Profile Picture

Haque 224

Last 30 days Overall leaderboard