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!
Solved! Go to Solution.
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:
Please consider take a try with above solution, check if the issue is solved.
Best regards,
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.
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})
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.
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:
Please consider take a try with above solution, check if the issue is solved.
Best regards,
Thank you for the reply! I will try it out in the morning and provide an update.
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,
The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.
This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.
User | Count |
---|---|
190 | |
53 | |
51 | |
34 | |
33 |
User | Count |
---|---|
268 | |
91 | |
80 | |
68 | |
67 |