web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Filter sharepoint list...
Power Apps
Answered

Filter sharepoint list dynamically in a collection

(0) ShareShare
ReportReport
Posted on 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:
I have the same question (0)
  • Verified answer
    WarrenBelz Profile Picture
    153,781 Most Valuable Professional on at

    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

  • AdaEloka Profile Picture
    on at

    @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. 

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

    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 
     ) 
     )
     )
    )

     

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 93 Most Valuable Professional

#2
Haque Profile Picture

Haque 81

#3
Valantis Profile Picture

Valantis 49

Last 30 days Overall leaderboard