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"
Solved! Go to Solution.
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))
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.
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))
I was going off the values you posted when I responded - glad you got it sorted.
The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.
This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.
User | Count |
---|---|
177 | |
52 | |
41 | |
36 | |
27 |
User | Count |
---|---|
243 | |
81 | |
71 | |
69 | |
66 |