Skip to main content

Notifications

Power Apps - Building 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:
  • WarrenBelz Profile Picture
    WarrenBelz 145,567 on at
    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
    AdaEloka on at
    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
    WarrenBelz 145,567 on at
    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

Microsoft Kickstarter Events…

Register for Microsoft Kickstarter Events…

Announcing Our 2025 Season 1 Super Users!

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

Announcing Forum Attachment Improvements!

We're excited to announce that attachments for replies in forums and improved…

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 145,567

#2
RandyHayes Profile Picture

RandyHayes 76,287

#3
Pstork1 Profile Picture

Pstork1 64,907

Leaderboard