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 Apps / ForAll filtering a col...
Power Apps
Answered

ForAll filtering a collection based on column in other collection

(0) ShareShare
ReportReport
Posted on by 2,987 Moderator

Hi

 

I'm hoping someone can give me a steer - I'm pretty sure this is simple, but I have made it difficult 😕

 

I have built an app and am currently trying to complete the last element. I'm stuck on trying to shape/filter my collection within a ForAll step, which passes each batch of filtered data as an input parameter to a flow. I'm OK with the flow / passing the parameters/JSON etc and had this all working fine. It's just now when I try to compile and pass more input parameters, I'm struggling with the shaping of this added data etc.

 

In the app, users can select multiple recipients from multiple orgs and in doing so create a collection (Collection1) like the following:

OrgUser
Org1UserA
Org1UserB
Org2UserC
Org2UserD
Org2UserE

 

As part of my flow, I want to pass the details for each org as a separate run i.e. Flow run 1 for just Org 1 users, Flow run 2 for just Org 2 users etc etc

 

I 'thought' the easy way to shape the data like that was to create a distinct collection of the Orgs (Collection2) and use this as the source in a Forall action, which would loop through each org and filter Collection1 based on the current value in the ForAll loop. Using the distinct function, Collection2 looks like this:

 

Result
Org1
Org2

 

Though, when I try to do this I cannot seem to get 'ThisRecord.Result' in the ForAll source loop to present inside the filter function within my ForAll. ThisRecord inside the Filter loop defaults to ThisRecord of Collection1 instead of Collection2

 

Any advice would be much appreciated.

 

Thank you.

Categories:
I have the same question (0)
  • Verified answer
    RandyHayes Profile Picture
    76,297 Super User 2024 Season 1 on at

    @AmDev 

    Sounds like you need to consider GroupBy instead of distinct.

    Consider the following:

    ForAll(GroupBy(yourCollection, "Org", "_recs"),
     yourFlow.Run(JSON(_recs))
    )

    Of course, the above completely hypothetical based on what you mention in the post, but the concept is, Group the collection by the Org.  The _recs column result will then have all of the Users for that Org in it.  So, you are just simply referencing the _recs table to get what you need.

     

    I hope this is helpful for you.

  • Gerard Simpson Profile Picture
    2,987 Moderator on at

    @RandyHayes  - Perfect, many thanks for this. Exactly what I needed (along with some free education on the groupby function.. 👍)

  • RandyHayes Profile Picture
    76,297 Super User 2024 Season 1 on at

    @AmDev 

    Always happy to help!

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 Apps

#1
WarrenBelz Profile Picture

WarrenBelz 721 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 320 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard