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 / Filter Gallery with Bu...
Power Apps
Answered

Filter Gallery with Buttons using Option Sets

(0) ShareShare
ReportReport
Posted on by 27

Hi,

 

I've read through countless topics here to try to figure out how to display all of the items in a gallery pressing a button but still could not get it to work correctly. I'm new to Powerapps and trying to recreate an app for my job so I'm probably missing something simple.

 

Issue: 

Trying to filter a gallery from a CDS datasource using the following buttons: All, Open, Pending, Approved, Declined. The buttons are from an option set and when pressed should display items that match the status of the button pressed. I'm able to filter the gallery using every button except the All button. I would like the All button to display all items (Open, Pending, Approved, Declined) in the Gallery.

 

Here's what I have:

Buttons - UpdateContext({cFilter:'Status'.Open}), UpdateContext({cFilter:'Status'.Pending}), etc

Gallery - Filter(CASES, 'Status' = cFilter)

 

I've tried a number of different ways to display all of the items in the Gallery by clicking the All button but nothing worked. When I did get it to work the gallery wouldn't change when clicking the other buttons. 

 

Any help with this is appreciated. Thanks for reading!

Categories:
  • Drrickryp Profile Picture
    Super User 2024 Season 1 on at

    Hi @kcgov 

    Have your context variable create the entire filter instead of just the status part.

     

     UpdateContext({itemvar:Filter(Cases,'Status'.Open)})
     UpdateContext({itemvar:Filter(Cases, 'Status'.Pending)}), etc

     

    For the All button UpdateContext(itemvar:Cases}).  Set the Items property of the gallery to Itemvar

    and set the OnVisible property of the screen to UpdateContext(itemvar:Cases}) as the default for the Gallery so it will show all the cases without a filter. BTW itemvar is just an arbitrary name for the context variable, it could be anything you want.

  • kcgov Profile Picture
    27 on at

    Thanks for the quick reply! Although all of the gallery items appeared by default, unfortunately, selecting the button to filter the gallery did not work. I received errors from the name being invalid to the function 'Filter' having invalid arguments. As a quick test this is what I did:

     

    Open.OnSelect: UpdateContext({cFilter:Filter(CASES,'Case Status'.Open)})

    Items.Gallery: cFilter

    OnVisible.Screen: UpdateContext({cFilter:CASES})

  • Drrickryp Profile Picture
    Super User 2024 Season 1 on at

    Hi @kcgov 

    Take a look at this blog about filtering with option sets. https://michalguzowski.pl/how-to-work-with-option-set-in-powerapps/  to develop the correct syntax for your filter.  I think that is the problem.

  • Verified answer
    v-xida-msft Profile Picture
    Microsoft Employee on at

    Hi @kcgov ,

    Do you want to filter your Gallery Items based on the Buttons click against the Option Set Type column in your CDS Entity?

     

    Based on the formula that you mentioned, I think there is something wrong with it. I have made a test on my side, please try the following workaround:

    Set the OnSelect property of "All" button to following:

    Set(CurrStatus, "All")

    Set the OnSelect property of "Open" button to following:

    Set(CurrStatus, "Open")

    Set the OnSelect property of "Pending" button to following:

    Set(CurrStatus, "Pending")

    Set the OnSelect property of "Approved" button to following:

     

    Set(CurrStatus, "Approved")

     

    Set the OnSelect property of "Declined" button to following:

    Set(CurrStatus, "Declined")

     

    Set the Items property of the Gallery to following:

    Filter(
     CASES,
     If(
     CurrStatus = "All" || IsBlank(CurrStatus),
     true,
     CurrStatus = "Open",
     Status = [@StatusOptionSetName].Open,
     CurrStatus = "Pending",
     Status = [@StatusOptionSetName].Pending,
     CurrStatus = "Approved",
     Status = [@StatusOptionSetName].Approved,
     CurrStatus = "Declined",
     Status = [@StatusOptionSetName].Declined
     ) 
    )

    Note: The StatusOptionSetName represents the OptionSet name your Option Set column related to, please replace it with your own Option Set Name from your CDS.

     

    Please check and see if the following blog would help in your scenario:

    https://powerapps.microsoft.com/en-us/blog/option-sets-and-many-to-many-relationships-for-canvas-apps/

     

    Please consider take a try with above solution, check if the issue is solved.

     

    Best regards,

  • kcgov Profile Picture
    27 on at

    Thank you for the reply! I will try it out in the morning and provide an update.

  • v-xida-msft Profile Picture
    Microsoft Employee on at

    Hi @kcgov ,

    Sure. Please take a try with the solution I provided, check if the issue is solved. If you have some issues with it, please feel free to let me know here.

     

    Regards,

  • kcgov Profile Picture
    27 on at

    @v-xida-msft,

     

    Your solution worked, thank you! 

  • Elvinho Profile Picture
    2 on at

    Thank you so much!!!!

     

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

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 345 Super User 2026 Season 2

#2
Mohsin Ali Profile Picture

Mohsin Ali 225

#3
M Bilal Khan Profile Picture

M Bilal Khan 192

Last 30 days Overall leaderboard