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 / How to compare two col...
Power Apps
Answered

How to compare two collections without using ForAll?

(0) ShareShare
ReportReport
Posted on by

Hi Folks,

 

I'm trying to compare two collections in canvas app:

 

Collection A:

IDDisplayName
123Group A
1222Group B
1342Group C

 

Collection B:

OfficeGroupIDDisplayName
111testname1
1222testname2
1342testname3
101testname4
102testname5
103testname6

 

I need to compare these two collections and return true if at least one of the IDs in Collection A is present in Collection B. Is there anyway I can compare this without using ForAll in canvas app?

Categories:
  • BCBuizer Profile Picture
    22,899 Super User 2026 Season 2 on at

    Hi @rbn_nue ,

     

    May I ask why ForAll can't be used?

     

    The only other way I can think of is by using recursion, but that is more complicated to build.

  • rbn_nue Profile Picture
    on at

    Hi @BCBuizer 

     

    The number of both rows in real time scenario is much higher. Just trying to best method without slowing down the app.

     

    Thanks.

  • BCBuizer Profile Picture
    22,899 Super User 2026 Season 2 on at

    Hi @rbn_nue ,

     

    Please try the below to see how the performance is. For me it responded quite quickly on two collections that had 1000 items each.

     

    Sum(
     ForAll(
     'Collection A'.ID,
     If(ThisRecord in 'Collection B'.ID, 1,0)
     ),
     Value
    )>0

     

  • rbn_nue Profile Picture
    on at

    Hi @BCBuizer 

     

    I had already used forAll and it was quite fast. But looks like the code you provided is much more optimized. Will try this and let you know.

     

    Thank you. 

  • Verified answer
    rswain Profile Picture
    173 on at

     

    Yes, you can use the Filter function to accomplish this without using ForAll. Here's an example formula that should work:
    
    CountRows(Filter(CollectionB, OfficeGroupID in CollectionA.ID)) > 0
    
    
    This formula uses the Filter function to create a new collection containing only the items in CollectionB where the OfficeGroupID is present in CollectionA.ID. The CountRows function is then used to count the number of items in this filtered collection. If the count is greater than 0, it means at least one ID from CollectionA is present in CollectionB. The formula returns true in this case, and false otherwise.

     

  • rbn_nue Profile Picture
    on at

    Hi @rswain 

     

    That worked! Thank you for the suggestion. 

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 360 Super User 2026 Season 2

#2
M Bilal Khan Profile Picture

M Bilal Khan 325

#3
Mohsin Ali Profile Picture

Mohsin Ali 232

Last 30 days Overall leaderboard