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 / ClearCollect & Filter
Power Apps
Answered

ClearCollect & Filter

(1) ShareShare
ReportReport
Posted on by 4
I'm new to PowerApps. I had someone in my company who was very capable recently leave, so my source of review/corrections has also left. ChatGPT is not helping me solve this issue either as I've exhausted the troubleshooting and everything checks, so looking to you for help as I'm not getting the expected results.
 
I am building an app that collects and displays data. Screen1 has a dropdown list of projects (FilterDrop_ProjectName), which then populates a gallery (GalleryDesignPackageCategories) which is a checkbox list of categories. A user would then pick the categories they would like to see, and it populates the package details in another gallery (Gallery4). 
 
FilterDrop_ProjectName OnChange property I have:
UpdateContext({filteredProjectName: Trim(FilterDrop_ProjectName.Selected.NewProjectName)})
 
GalleryDesignPackageCategories (the gallery), Check_ProjectCategory (the repeating check box populated by ProjectName) OnCheck property I have: 
Collect(SelectedPackageCategories, ThisItem.Value)
 
Table '[DPC] Design Package Coordinations' has the following columns:
ProjectName - Text
PackageCategory - Text
 
Screen1 OnVisible property I have:
ClearCollect(
    colGallery4Data,
    Filter(
        '[DPC] Design Package Coordinations',
        ProjectName = filteredProjectName && PackageCategory in SelectedPackageCategories
    )
);
 
When I add a text label to count the rows of colGallery4Data, it ends up as 0, but it should return 8. I've reduced the ClearCollect to try and show just ProjectName or PackageCategory, but no matter what it comes back 0, and won't populate my Gallery4 content. What's wrong with my ClearCollect or Filter functions? 
Categories:
I have the same question (0)
  • Suggested answer
    WarrenBelz Profile Picture
    154,496 Most Valuable Professional on at
    Firstly (small improvement on this one) - FilterDrop_ProjectName OnChange
    UpdateContext({filteredProjectName: Self.Selected.NewProjectName})
    GalleryDesignPackageCategories  -  Check_ProjectCategory OnCheck
    Collect(SelectedPackageCategories, ThisItem)
    Screen1 OnVisible (I assume you are changing to this after you set the items above)
    ClearCollect(
       colGallery4Data,
       Filter(
          '[DPC] Design Package Coordinations',
          ProjectName = filteredProjectName && PackageCategory in SelectedPackageCategories.PackageCategory
       )
    );
    If you are concerned about Delegation on the last one
    With(
       {
          _Data:
          Filter(
             '[DPC] Design Package Coordinations',
             ProjectName = filteredProjectName
          )
       },
       ClearCollect(
          colGallery4Data,
          Filter(
             _Data,
             PackageCategory in SelectedPackageCategories.PackageCategory
          )
       )
    )

    ​​​​​​​Please click Does this answer your question 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 a Like.
    MVP (Business Applications)    Visit my blog Practical Power Apps    LinkedIn    Buy me a coffee
  • MR-14011956-0 Profile Picture
    4 on at
    Thank you @WarrenBelz. 
     
    I did make the suggestions that you have made. Because PackageCategory wasn't recognized after SelectedPackageCategories, I updated to this:
    With(
       {
          _Data:
          Filter(
             '[DPC] Design Package Coordinations',
             ProjectName = filteredProjectName
          )
       },
       ClearCollect(
          colGallery4Data,
          Filter(
             _Data,
             PackageCategory in SelectedPackageCategories
          )
       )
    );
    Could that small update have an impact on my results? 
     
    Besides that, I've restarted the app and I continue to get nothing back:
    colGallery4Data rows: 0
  • WarrenBelz Profile Picture
    154,496 Most Valuable Professional on at
    The key here is the change I made to the OnSelect of the checkbox in the Gallery, assuming you had records in there to select
    Collect(SelectedPackageCategories, ThisItem)
    What is the Items of GalleryDesignPackageCategories and the Default of Check_ProjectCategory ?
  • MR-14011956-0 Profile Picture
    4 on at
    Thank you for the response and help! Ok, I had that code on OnCheck of Check_ProjectCategory, but you're saying I should instead put it on OnSelect of GalleryDesignPackageCategories? I have tried that, but there is still no change. I currently put it back to OnCheck of Check_ProjectCategory. Here's the other codes you asked about:
     
    Items for GalleryDesignPackageCategories:
    Distinct(
        Filter(
            '[DPC] Design Package Coordinations',
            ProjectName = FilterDrop_ProjectName1.Selected.NewProjectName
        ),
        PackageCategory
    )
    Default for Check_ProjectCategory:
    false
    Default for GalleryDesignPackageCategories:
    false
     
     
  • Verified answer
    WarrenBelz Profile Picture
    154,496 Most Valuable Professional on at
    OK - I see now your gallery is a one-field item with (I assume) the checkboxes displaying the Value field, so for the last Collection
    With(
       {
          _Data:
          Filter(
             '[DPC] Design Package Coordinations',
             ProjectName = filteredProjectName
          )
       },
       ClearCollect(
          colGallery4Data,
          Filter(
             _Data,
             PackageCategory in SelectedPackageCategories.Value
          )
       )
    );
     
    Please click Does this answer your question 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 a Like.
    MVP (Business Applications)    Visit my blog Practical Power Apps    LinkedIn    Buy me a coffee
  • WarrenBelz Profile Picture
    154,496 Most Valuable Professional on at
    A quick follow-up to see if you received the answer you were looking for or if you need further assistance.

    Please click Does this answer your question 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 a Like.
    MVP (Business Applications)    Visit my blog Practical Power Apps    LinkedIn   

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

#2
Haque Profile Picture

Haque 230

#3
Kalathiya Profile Picture

Kalathiya 217 Super User 2026 Season 1

Last 30 days Overall leaderboard