Skip to main content

Notifications

Community site session details

Community site session details

Session Id : 8QUwvawZehGeTXbC0+pqQu
Power Apps - Building Power Apps
Answered

Filter gallery based on rows checked or unchecked

Like (1) ShareShare
ReportReport
Posted on 22 Mar 2024 14:50:25 by 41

I have a gallery that's populated with a collection from a SQL Data Source

Johnane_0-1711118627882.png

I want to be able to filter the gallery based on whichever radio button I select.

Currently I have the checkboxes set up like this:

OnCheck: Collect(checkedRow,ThisItem)

OnUncheck: Collect(uncheckedRow,ThisItem)

 

But this solution only creates a collection for the OnCheck (Makes sense since I don't uncheck some rows so those lines won't be saved in the uncheckedRow collection)

 

How can I set up the gallery to show only the checked and unchecked rows based on the radio button selected.

Also, how to I set the uncheckRow collection to populate all the unchecked rows?

  • Johnane Profile Picture
    41 on 11 Apr 2024 at 10:01:21
    Re: Filter gallery based on rows checked or unchecked

    @jrletner Thank you. It makes a lot of sense. I've managed to get it right. Had to set the default for the checkbox to the column in the collection.

  • jrletner Profile Picture
    720 Super User 2025 Season 1 on 28 Mar 2024 at 19:13:21
    Re: Filter gallery based on rows checked or unchecked

    Screen Recording 2024-03-28 at 2.10.02 PM.gif

  • jrletner Profile Picture
    720 Super User 2025 Season 1 on 28 Mar 2024 at 19:08:36
    Re: Filter gallery based on rows checked or unchecked

    @Johnane ok, hopefully this will be a little more helpful for you.

    If(
     varIsChecked = Blank(),
     colChecked,
     Filter(
     colChecked,
     isChecked = varIsChecked
     )
    )

    isChecked is a column in my collection. When the item is checked in the gallery, it patches the collection, setting the isChecked to true. When it is unChecked, it patches the collection setting the isChecked value to false.

    // onCheck Code:
    
    Patch(colChecked,ThisItem,{isChecked: true})

     

    // OnUncheck Code:
    
    Patch(colChecked,ThisItem,{isChecked: false})


    So the gallery filters based off of those values in the collection:

    If(
     varIsChecked = Blank(),
     colChecked,
     Filter(
     colChecked,
     isChecked = varIsChecked
     )
    )


    I added code comments to walk you through the filtering of the gallery (filtering can be confusing):

     

    * If the user chooses "All items" in the radio button, I set the varChecked variable to Blank() to display all items

     

    * If the user chooses "Checked" in the radio button, I set the varChecked variable to TRUE, and the gallery is filtered to show only Checked items.

     

    * If the user chooses "Unchecked" in the radio button, I set the varChecked variable to FALSE, and the gallery is filtered to show only UnChecked items.

  • Johnane Profile Picture
    41 on 27 Mar 2024 at 08:36:29
    Re: Filter gallery based on rows checked or unchecked

    What is the Checked in the Gallery Items?

    Johnane_0-1711528581739.png

    I do not set the checkbox dynamically on my side. I only drag the control over and check when running the app. How do I identify when a user has checked?

     

    I think I should note that the gallery is populated by a collection from a sql db

  • jrletner Profile Picture
    720 Super User 2025 Season 1 on 25 Mar 2024 at 12:30:51
    Re: Filter gallery based on rows checked or unchecked

    @Johnane for this example of how to filter by checked / unchecked, for the checkboxes, I didn't have any code in the checkbox itself. I did, however, have a button on the screen that created some dummy data for the example. I just set two checkbox values to TRUE and the rest to FALSE.

    ClearCollect(
     colChecked,
     {
     ID: 1,
     Checked: false
     },
     {
     ID: 2,
     Checked: true
     },
     {
     ID: 3,
     Checked: true
     },
     {
     ID: 4,
     Checked: false
     }
    )


    Then I just had the gallery point to that collection.

  • Johnane Profile Picture
    41 on 25 Mar 2024 at 06:55:42
    Re: Filter gallery based on rows checked or unchecked

    What was the property you set on the checkbox?

  • Verified answer
    jrletner Profile Picture
    720 Super User 2025 Season 1 on 23 Mar 2024 at 16:49:18
    Re: Filter gallery based on rows checked or unchecked

    @Johnane  Hope this helps...in my example, I created a radio box that has "All Items", "Checked", and "Unchecked".

    Step 1:  For the radio box, i placed this code in the OnChange property:

     

    If(
     Self.Selected.Value = "All Items",
     Set(
     varIsChecked,
     Blank()
     ),
     If(
     Self.Selected.Value = "Checked",
     Set(
     varIsChecked,
     true
     ),
     Set(
     varIsChecked,
     false
     )
     )
    )

     
    Step 2: In the gallery, I placed this code in the Items property:

     

    If(
     varIsChecked = Blank(),
     colChecked,
     Filter(
     colChecked,
     Checked = varIsChecked
     )
    )


    RESULTS:

    When "All Items" is selected:

    jrletner_0-1711212450935.png


    When "Checked" is selected:

    jrletner_1-1711212482797.png


    When "Unchecked" is selected:

    jrletner_2-1711212516613.png





    If my post helped you solve your issue, please click 'Accept as solution.' This will assist others in finding the solution more easily and will also close the item. If you found the content useful in other ways, feel free to give it 'Thumbs Up.'

     

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

Understanding Microsoft Agents - Introductory Session

Confused about how agents work across the Microsoft ecosystem? Register today!

Warren Belz – Community Spotlight

We are honored to recognize Warren Belz as our May 2025 Community…

Congratulations to the April Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard > Power Apps - Building Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 89 Most Valuable Professional

#2
MS.Ragavendar Profile Picture

MS.Ragavendar 58

#3
Michael E. Gernaey Profile Picture

Michael E. Gernaey 42 Super User 2025 Season 1

Overall leaderboard