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 / Filter a collection wh...
Power Apps
Answered

Filter a collection while looping another collection

(0) ShareShare
ReportReport
Posted on by 997 Super User 2024 Season 1

Hi,

I have created a collection that is filtered by the Manager's Name in the Sharepoint list. Then I would like to create a new collection that filters the Requester column which is a people column in the Leave Request list and match it with the Name in the subordinates collection. 

 

anonymous21_0-1658736818591.pnganonymous21_1-1658736903307.png

I tried using this formula but has errors.

ClearCollect(subordinates,Filter(Employee,'Manager''s Name'.Email=CurrentUser));
ForAll(subordinates,
Collect(NewSubordinates,Filter('Leave-Request',Requester.DisplayName=LookUp(subordinates,Name.DisplayName=Requester.DisplayName))));

Can someone please help me?

 

Thank you.

 

Categories:
I have the same question (0)
  • WarrenBelz Profile Picture
    153,079 Most Valuable Professional on at

    @syhrh ,

    Try this

    With(
     {
     wSub:
     Filter(
     Employee,
     'Manager''s Name'.Email = CurrentUser
     )
     },
     ForAll(
     wSub As aCol,
     Collect(
     NewSubordinates,
     Filter(
     'Leave-Request',
     Requester.DisplayName = aCol.Name.DisplayName
     )
     )
     )
    );

     

    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

  • syhrh Profile Picture
    997 Super User 2024 Season 1 on at

    @WarrenBelz It works but it also creates many duplicates and add up into the collection

  • WarrenBelz Profile Picture
    153,079 Most Valuable Professional on at

    Hi @syhrh ,

    That is probably more an issue with your data . You only really have two choices - multiple (as posted previously) or single (the first) matches in your List - single as below

    With(
     {
     wSub:
     Filter(
     Employee,
     'Manager''s Name'.Email = CurrentUser
     )
     },
     ForAll(
     wSub As aCol,
     Collect(
     NewSubordinates,
     LookUp(
     'Leave-Request',
     Requester.DisplayName = aCol.Name.DisplayName
     )
     )
     )
    );

     

    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

     

  • syhrh Profile Picture
    997 Super User 2024 Season 1 on at

    @WarrenBelz 

    it works but it has delegation issues

    anonymous21_0-1658800050418.png

     

  • Verified answer
    WarrenBelz Profile Picture
    153,079 Most Valuable Professional on at

    @syhrh 

    Assuming that you will never need to look in more than the newest 500 (or whatever your Delegation limit is) records in 'Leave Request'

    With(
     {
     wSub:
     Filter(
     Employee,
     'Manager''s Name'.Email = CurrentUser
     ),
     wLeave:
     Sort(
     'Leave-Request',
     ID,
     Descending
     )
     },
     
     ForAll(
     wSub As aCol,
     Collect(
     NewSubordinates,
     LookUp(
     wLeave,
     Requester.DisplayName = aCol.Name.DisplayName
     )
     )
     )
    )

     

    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

  • syhrh Profile Picture
    997 Super User 2024 Season 1 on at

    @WarrenBelz Can I use Filter instead? If I use LookUp, there are some rows from SharePoint that are not retrieved.

  • WarrenBelz Profile Picture
    153,079 Most Valuable Professional on at

    @syhrh ,

    Yes, you can use Filter, but as you said earlier, there may be duplicates.

     

    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

  • syhrh Profile Picture
    997 Super User 2024 Season 1 on at

    @WarrenBelz If I put First, will there be no duplicates?

  • WarrenBelz Profile Picture
    153,079 Most Valuable Professional on at

    @syhrh ,

    No - First is exactly the same result as LookUp.

  • syhrh Profile Picture
    997 Super User 2024 Season 1 on at

    @WarrenBelz Oh, okay then. Thank you.

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 739 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 343 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard