cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
landonjochim
Resolver I
Resolver I

How to filter based on one of the items in a record column being in another collections record column

I have a Variable (varFunction) which has a record column (roles) and a collection of users (colHeritageManagement) who also have a record column (Roles). I want to get a list of the users from colHeritageManagement that's Roles column contains one of the results from Roles column from varFunction.

 

Below is what I have currently and I cannot seem to get this figured out. I am not getting any errors, but the items in the Gallery are not correct. Seem to have the columns but no data is coming in.

 

ForAll(varFunction.roles.Result As _role, Filter(colHeritageManagement As _user, _role.Result in _user.Roles.Value))

 

varFunction Variable: Want to search the collection for any items that Role column contain either "Administrative Tasks" or "Talent Management"

landonjochim_0-1637006494857.png

landonjochim_1-1637006523972.png

 

landonjochim_2-1637006725518.png

landonjochim_4-1637006815582.png

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions

This took me quite awhile and looking at multiple posts. The issue was I kept using a ForAll because I wanted to see if any of the varFunction.roles.Results were inside each colHertiageManagement.Roles.Values. And the ForAll would not return a true/false result to show that user in the Gallery.

The CountIf solved this for me. Here is the post that helped https://powerusers.microsoft.com/t5/Building-Power-Apps/Breaking-from-ForAll-loop-or-using-set-insid... 

 

Here is the working formula:

Filter(colHeritageManagement, If(CountIf(Roles, Value in varFunction.roles.Result)>0,true,false))

 

View solution in original post

4 REPLIES 4
WarrenBelz
Super User
Super User

Hi @landonjochim ,

Are you trying to create another collection or filter a gallery?

For a Collection

ClearCollect(
   colFiltered,
   Filter(
      colHeritageManagement,
      Result in varFunction.Roles.Value
   )
)

gallery Items would simply be

Filter(
   colHeritageManagement,
   Result in varFunction.Roles.Value
)

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

Visit my blog Practical Power Apps

I am filtering a gallery. Couple things from your reply; Result is not a valid identifier where you placed it. Also, varFunction.roles cannot be .Value, but .Result only.

landonjochim_0-1637071835416.png

 

This took me quite awhile and looking at multiple posts. The issue was I kept using a ForAll because I wanted to see if any of the varFunction.roles.Results were inside each colHertiageManagement.Roles.Values. And the ForAll would not return a true/false result to show that user in the Gallery.

The CountIf solved this for me. Here is the post that helped https://powerusers.microsoft.com/t5/Building-Power-Apps/Breaking-from-ForAll-loop-or-using-set-insid... 

 

Here is the working formula:

Filter(colHeritageManagement, If(CountIf(Roles, Value in varFunction.roles.Result)>0,true,false))

 

@landonjochim ,

I was going off the values you posted when I responded - glad you got it sorted.

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

May UG Leader Call Carousel 768x460.png

June User Group Leader Call

Join us on June 28 for our monthly User Group leader call!

PA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.

PA.JPG

New Release Planning Portal (Preview)

Check out our new release planning portal, an interactive way to plan and prepare for upcoming features in Power Platform.

Top Solution Authors
Users online (1,383)