Skip to main content
Community site session details

Community site session details

Session Id : MOqf768fejxj3lfU0hoV5y
Power Apps - Building Power Apps
Answered

Filter sharepoint list dynamically in a collection

Like (0) ShareShare
ReportReport
Posted on 15 Jan 2024 20:02:45 by

Hello everyone,

 

I'm trying to filter a sharepoint source into a collection based on items in a gallery. So for example, my gallery has the following items - "Facility, Horticulture..." then I have a collection that I need to filter to show items that have facility or horticulture as the unit or whatever items that are in the gallery. My problem is, I don't know how to do it. I've tried different things that haven't worked. Any help will be appreciated. This is what I have in my code now...I've commented out the different things i've tried/am trying.

 

ClearCollect(
 colBudgetFilter,
 If(
 User().Email = varDeptHead,
 Filter(
 Budgets,
 Department = varDept,
 Conso = "Admin Costs",
 Year = Text(Year(Today()))
 ),
 Filter(
 Budgets,
 //Unit = "Facility" || Unit = "Horticulture",
 //Unit = Concat(Gallery2.AllItems, Unit, "; "),
 //ForAll(Gallery2.AllItems, Unit = 
 Conso = "Admin Costs",
 Year = Text(Year(Today()))
 )
 )
);

 

Categories:
  • WarrenBelz Profile Picture
    148,857 Most Valuable Professional on 15 Jan 2024 at 22:32:10
    Re: Filter sharepoint list dynamically in a collection

    Hi @AdaEloka ,

    You can go a step further eliminating duplicated code

    With(
     {
     _Data: 
     Filter(
     Budgets,
     Conso = "Admin Costs" && 
     Year = Text(Year(Today()))
     ),
     _Gal: 
     Concat(
     Gallery2.AllItems,
     Unit,
     "; "
     )
     },
     ClearCollect(
     colBudgetFilter,
     If(
     User().Email = varDeptHead,
     Filter(
     _Data,
     Department = varDept
     ),
     Filter(
     _Data,
     varUnitHead ||
     Unit in _Gal 
     ) 
     )
     )
    )

     

  • AdaEloka Profile Picture
    on 15 Jan 2024 at 22:19:52
    Re: Filter sharepoint list dynamically in a collection

    @WarrenBelz Wow, this worked! Although I tweaked it a bit. But pls, could you explain the logic? I would like to understand it. Right now, I'm not sure why it worked, I just know it did...

     

    This is my version of the code...

     

    ClearCollect(
     colBudgetFilter,
     If(
     User().Email = varDeptHead,
     Filter(
     Budgets,
     Department = varDept,
     Conso = "Admin Costs",
     Year = Text(Year(Today()))
     ),
     With(
     {
     _Data: Filter(
     Budgets,
     Conso = "Admin Costs" && Year = Text(Year(Today()))
     ),
     _Gal: Concat(
     Gallery2.AllItems,
     Unit,
     "; "
     )
     },
     Filter(
     _Data,
     varUnitHead ||
     Unit in _Gal
     )
     )
     )
    );

     

    Thank you. 

  • Verified answer
    WarrenBelz Profile Picture
    148,857 Most Valuable Professional on 15 Jan 2024 at 20:45:15
    Re: Filter sharepoint list dynamically in a collection

    Hi @AdaEloka ,

    Is this what you are trying to do ?

    With(
     {
     _Data:
     Filter( 
     Budgets,
     Department = varDept &&
     Conso = "Admin Costs" &&
     Year = Text(Year(Today()))
     ),
     _Gal: Concat(Gallery2.AllItems, Unit, "; ")
     },
     Filter(
     _Data,
     !varDeptHead ||
     Unit in _Gal
     )
    )

     

    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.

    MVP (Business Applications)   Visit my blog Practical Power Apps

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

Announcing our 2025 Season 2 Super Users!

A new season of Super Users has arrived, and we are so grateful for…

Paul Stork – Community Spotlight

We are honored to recognize Paul Stork as our July 2025 Community…

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 791 Most Valuable Professional

#2
MS.Ragavendar Profile Picture

MS.Ragavendar 410 Super User 2025 Season 2

#3
mmbr1606 Profile Picture

mmbr1606 275 Super User 2025 Season 2

Loading complete