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 / Select limited checkbo...
Power Apps
Unanswered

Select limited checkboxes from gallery

(0) ShareShare
ReportReport
Posted on by 30

I have a gallery control with checkbox on each row. I have a "Select All" button outside the gallery. When click on "Select All" button then first 10 checkbox should be checked out of available records in the PowerApps gallery.

Categories:
I have the same question (0)
  • SpongYe Profile Picture
    5,715 Super User 2026 Season 1 on at

    Hi @nsmarathe 

     

    A way to achieve your goal is to use a variable to store the number of items you want to select in the gallery, and then use a ForAll loop to iterate over the gallery items and set the checkbox value to true for the first n items.

     

    For example, you can try the following steps:

    • Create a variable called

     

     

    numSelect​

     

     and set its value to 10 in the OnStart property of your app. This variable will control how many items you want to select in the gallery.

     

    • Set the Default property of the checkbox in the gallery to 

     

     

    IsSelected

     

    which will indicate whether the item is selected or not.

     

    • Set the OnCheck property of the checkbox to 

     

     

    UpdateContext({IsSelected:true})

     

    which will update the context variable for the current item when the checkbox is checked.

     

    • Set the OnUncheck property of the checkbox to 

     

     

    UpdateContext({IsSelected:false})

     

    which will update the context variable for the current item when the checkbox is unchecked.

     

    • Set the OnSelect property of the “Select All” button to 

     

     

    ForAll(FirstN(Gallery.AllItems,numSelect),UpdateContext({IsSelected:true}))

     

    which will loop through the first 10 items in the gallery and set their context variables to true.

     

    If you have any questions or feedback, please let me know. Have a great day! 😊

    -----------------------
    PowerYsa Power Platform Enthusiast [LinkedIn] | [Youtube]

    I love to share my knowledge and learn from others. If you find my posts helpful, please give them a thumbs up 👍 or mark them as a solution ✔️. You can also check out my [@PowerYSA] for some cool solutions and insights. Feel free to connect with me on any of the platforms above. Cheers! 🍻

  • nsmarathe Profile Picture
    30 on at

    Hi,

    getting below errors.

    1. OnCheck/OnUncheck of the checkbox in gallery

    nsmarathe_0-1696652290580.png

     

    2. getting error on OnSelect property of the “Select All” button

    nsmarathe_1-1696652346441.png

     

  • TechRanger Profile Picture
    15 on at

    I feel a collection is the easiest to do for check boxes. 

    OnCheck: Collect(colchk, Thisitem.Text)

    Uncheck: RemoveIf(Thisitem.Text in colchk.Value)

    Default: Thisitem.Text in colchk.Value

     

    For the select all that is a little tricky. Depending on the item in the gallery if a collection or from the source

    Got a couple options

     

    OnCheck: ClearCollect(colchk,gallery.allitems)

    or if using a collection for gallery item

    OnCheck: ClearCollect(colchk, colgalitems)


    I usually recommend to put the gallery items in a collection to make it easier to use and change if needed

  • SpongYe Profile Picture
    5,715 Super User 2026 Season 1 on at

    Hi @nsmarathe 

     

    Sorry for the confusion. I recreated your use case as followed:

     

    • Create a variable called varNumSelect and set its value to 10 in the OnStart property of your app. This variable will control how many items you want to select in the gallery. 

     

    varNumSelect​

     

    • Set the Default property of your checkbox control inside the gallery to which is a boolean value that indicates whether the item is selected or not. 

     

    ThisItem.IsSelected

     

    • Set the OnCheck and OnUncheck properties of your checkbox control to 

     

    //OnCheck
    Patch(ThisItem, {IsSelected: true})

     and 

    //OnUnCheck
    Patch(ThisItem, {IsSelected: false})

     respectively. This will update the IsSelected value of the item in the data source when you check or uncheck the checkbox.

     

    • Set the OnSelect property of your “Select All” button to 

     

    ForAll(
     FirstN(Gallery1.AllItems, varSelectCount), 
     Patch(ThisRecord, {IsSelected: true})
    )

    . This will loop through the first 10 items in the gallery and set their IsSelected value to true.

     

     

    If you have any questions or feedback, please let me know. Have a great day! 😊

    -----------------------
    PowerYsa Power Platform Enthusiast [LinkedIn] | [Youtube]

    I love to share my knowledge and learn from others. If you find my posts helpful, please give them a thumbs up 👍 or mark them as a solution ✔️. You can also check out my [@PowerYSA] for some cool solutions and insights. Feel free to connect with me on any of the platforms above. Cheers! 🍻

  • nsmarathe Profile Picture
    30 on at

    Hi,

     

    Thanks for your suggestions. Unfortunately it is still not working.

  • TechRanger Profile Picture
    15 on at

    You might want to try this, this would be both for the screen and the gallery. I will start with the screen code then gallery. Then what you need for the “Select All” button. Going to use numbers as the gallery items for this example. 

    For the screen-

     

    OnVisible: ClearCollect(colGalItems, [“1”,”2”,”3”])

     

    Gallery-

     

    Items: colGalItems

     

    add the checkbox to the gallery

     

    Checkbox-

     

    Oncheck: Collect(colNumSel, Thisitem.Text)

     

    Uncheck: RemoveIf(colNumSel, Thisitem.Text in Value) 


    Realized my last message had an error on that, apologize for that

     

    Default: Thisitem.Text in colNumSel.Value

     

    for the “Select All” button 

     

    Button-

     

    OnSelect: ClearCollect(colNumSel, colGalItems);

     

    When you hit the button it should fill colNumSel with all the items in the collection. 

    If you check the collections and variables area you should see the collection fill. All the checkboxes should be checked off once pushed. 

    I am currently away from my computer, I have the same setup you described on an app. If still not working, let me know and once I get back to the my computer. I will double check the solution on that app. 

     

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!

Congratulations to the March Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 577

#2
WarrenBelz Profile Picture

WarrenBelz 440 Most Valuable Professional

#3
Haque Profile Picture

Haque 308

Last 30 days Overall leaderboard