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 / Set checkbox based on ...
Power Apps
Answered

Set checkbox based on collection

(1) ShareShare
ReportReport
Posted on by 8

Hello. I am new to PowerApps and really in need of some help. Your time is appreciate in advance!

I have a gallery with check boxes as the first column. I have most of it figured out except for one thing. 

When the user selects the checkbox it will put the item in a collection. When they unselect it will take it out of the collection. So far too easy. 

My issue is when I filter the gallery to find items I'm looking for, then clear my filters to show all the records in the gallery, items I had check become unchecked....but the are still in the collection. 

How can I keep these check boxes checked even after doing some filtering and then clearing the filtering and All records are showing again. 

Categories:
I have the same question (0)
  • poweractivate Profile Picture
    11,078 Most Valuable Professional on at

    @Dan_K 

     

    What is value of the OnSelect of the Checkbox? I also presume the Checkbox is inside the Gallery?

     

    What is the value of Items for the Gallery?

     

    As a guess even without knowing the above, the Gallery might have Items referencing a Data source, but the Checkbox updates some other Collection that is not related to the Gallery at all. Another guess is that the Checkbox is somehow not actually updating the Collection.

  • Dan_K Profile Picture
    8 on at

    Thanks for chiming in! Here is what I have so far....

    OnCheck: Collect(CollectionSelectedItems,This item)

    OnSelect: Select(Parent)

    OnUncheck: Remove(CollectionSelectedItem.ThisItem)

     

    You are correct that the checkbox is in the gallery. So that way every line in the gallery has its own checkbox allowing the user to select individual items. 

     

    The value of the items in the gallery are just text values. 

     

    The datasource for the gallery is pointing to a SharePoint list. Though not my ideal source it's all I have for the moment lol. 

     

    Just for clarify. When I click the check box I looked at the collection and all items selected in the gal appear in the collection. If I unclick the box the item will be removed from the collection. All good here so far.

    Again my hang up is when I have items selected, then filter the gallery to continue look through records, I then clear my filters when done searching for items I want to select...when the gallery go back to it's original state all my selected boxes become unselected. However the items that were selected (now showing unselected) still show up in the collection. Therefore if I selected the items again I now get duplicate items in the collection. 

     

    Hope this gives you what you need and then some. Feel free to ask any additional questions and thanks again for your assistance!

  • Verified answer
    v-chenzhi Profile Picture
    Microsoft Employee on at

    Hi @Dan_K ,

     

    I have a test on my side according to your scenario, please try the following workaround.

    I create a SharePoint list like this.

    vchenzhi_0-1638432369120.png

    After setting OnCheck and OnUncheck property,

    Set the Default property of CheckBox to:

    If(ThisItem.TText exactin CollectionSelectedItems.TText,true)

    vchenzhi_1-1638432490774.png

     

     

    Best Regards,

    Zhi Chen

     

     

  • Dan_K Profile Picture
    8 on at

    Hi @v-chenzhi 

    Thanks for your reply. Apologize for this long reply but I feel the detail is needed. I tried your approach and it did work, but there's a catch unfortunately. 

    So I selected my initial items. I then checked the collection to verify everything was captured. All good so far. I then filtered the gallery to find additional records. I selected the additional records I wanted then cleared my filters so the gallery would revert back to it's original look.

    My original selections remain selected per your formula. However once I unchecked them, they did not get removed from the collection.

    This was unfortunate but I was able to use your formula to create a solution.

    I created a label in the gal. So now each item has the label. I set the label text to say "added" using your formula. So now when I check the box, the checkbox visible is false and the label visible is true with the text property "added" to inform the user the item has been selected. 

    I then created a button "show selected" which brings up a pop-up object with a gal connected to the collection and gives the user ability to remove the items via the pop up. When they remove the items from the pop up, the label visible property in the gal visible becomes false and the check box visible becomes true defaulted to false. 

    Not the ideal approach but I was able to use your formula to make a solution. I will mark this as solved in hopes that's this helps others. But if you have any other suggestions please post them as I am not sure my approach is the best. But it works. Thank you again!!!!!

     

     

     

     

     

     

     

     

     

     

     

     

     

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 335 Most Valuable Professional

#2
11manish Profile Picture

11manish 166

#3
sannavajjala87 Profile Picture

sannavajjala87 71 Super User 2026 Season 1

Last 30 days Overall leaderboard