Showing results for 
Search instead for 
Did you mean: 
Helper I
Helper I

Filtering Gallery using Button

I have a Gallery that retrieves data from SharePoint List as a data source. 


I set the "Items" property in Gallery with this script: 
SortByColumns(Filter([@'AGM/EGM'], StartsWith(Title,TextSearchBox1.Text)),"MeetingDate", If(SortDescending1,Descending,Ascending))

Then, I created three buttons to filter the status of the items in the Gallery: Confirmed, In Review, Completed.

The Button's code: Filter('AGM/EGM',MeetingStatus.Value = "Confirmed")

It doesn't show any error message on the formula, but when I click on the button there's no action that has been made.


Any idea or suggestion?








Accepted Solutions

Hi @Kentgladwin99 ,

Using a drop down or three buttons are both ok.

The reason why you met problem is because of the MeetingStatus field data type.

Firstly, let me explain why your original solution is wrong:

If you want to change the items of the gallery, you need to set the gallery's Items property. Only the gallery's Items property affect the items displaying in the gallery. Setting the button's OnSelect to Filter()function will not change the items in the gallery. 


Here's my solution in details:

1)use buttons to filter:

set button1's OnSelect:


set button2's OnSelect:


Set(var,"In Review")


set button1's OnSelect:




set the gallery's Items:

              Filter([@'AGM/EGM'], StartsWith(Title,TextSearchBox1.Text),
                     If(IsBlank(var),true,MeetingStatus.Value =var)
"MeetingDate", If(SortDescending1,Descending,Ascending))

2)use a drop down to filter:

set the drop down's Items:

["Confirmed","In Review","Completed"]

set the gallery's Items:


              Filter([@'AGM/EGM'], StartsWith(Title,TextSearchBox1.Text),
                     MeetingStatus.Value =dropdown1.Selected.Value
"MeetingDate", If(SortDescending1,Descending,Ascending))



You could choose using buttons or a drop down to filter based on your demands.



Best regards,


Community Support Team _ Phoebe Liu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

Hi @Kentgladwin99 ,


I have the same question as yours before, and I solve this with a stupid but workable way 😝

Here's my method:

The 1st step is the same as previous posts; I set OnSelect = Set(Var, value) on each button.

For the gallery I want to filter, I set Items = If(Var=1, true, false) and the false condition will be "All Status".


For you, it might be as following:



Onselect = Set(var,"Confirmed")



Onselect = Set(var,"In Review")​



Onselect = Set(var,"Complete")​



If(var="Confirmed", SortByCouums(Filter([@YourDataSource],MeetingStatus.Value = "Confirmed"),"MeetingDate", If(SortDescending1,Descending,Ascending)),
  If(var="In Review", SortByCouums(Filter([@YourDataSource],MeetingStatus.Value = "In Review"),"MeetingDate", If(SortDescending1,Descending,Ascending)),
   If(var="Complete", SortByCouums(Filter([@YourDataSource],MeetingStatus.Value = "Complete"),"MeetingDate", If(SortDescending1,Descending,Ascending)),
  SortByCouums([@YourDataSource],"MeetingDate", If(SortDescending1,Descending,Ascending))


The most difficult part is to check and count the ")" for your If()..... 😓

If you found there's a better way, please also share with me.😉

View solution in original post

Super User
Super User

I suggest you rather filter with Drop-down. Set the dropdown items to :
["Confirmed", "In Review", "Completed"]

Then filter based on what the user selects
SortByColumns(Filter([@'AGM/EGM'], StartsWith(Title,TextSearchBox1.Text)&&'Meeting Status'=DropdownName.Selected.Value),"MeetingDate", If(SortDescending1,Descending,Ascending))
Regular Visitor

Hi @Kentgladwin99 

You are quite close. I think the problem is the Button is currently in isolation to gallery.

You may need a variable in Gallery Items expression to Filter by meeting status.

For example :

SortByColumns(Filter([@'AGM/EGM'], And(StartsWith(Title,TextSearchBox1.Text),MeetingStatus = varMeetingStatus) ),"MeetingDate", If(SortDescending1,Descending,Ascending)) 



Then in each button onSelect you can update the variable appropriately. i.e.

UpdateContext({varMeetingStatus: "Confirmed")


Let me know how u go. and plz accept the solution if works.

Hi @raheelr ,


I think you are right, the Filter buttons are isolation to the Gallery. 


Let me try to insert the code and see how it goes. 


Thank you! 

Hi @raheelr ,

I applied the code into the "Items" property in the Gallery. Unfortunately, it says invalid argument type. (The red curvy line are located underneath the "=" equal sign. 


But the code for the button has no error.


Any idea?

Hi @eka24 ,


You mean instead of creating a button to filter, we use a drop-down selection with three choices. 


And it filters when the user selected an option in the drop-down list. 


If so, I just remove the current buttons that I have and replace with a dropdown list, am I on the same path?





SortByColumns(Filter([@'AGM/EGM'], StartsWith(Title,TextSearchBox1.Text),MeetingStatus = varMeetingStatus ),"MeetingDate", If(SortDescending1,Descending,Ascending))


Remove the And()

Yes I think that would be simpler. Follow the post I gave and get back if any issues come up

Hi @raheelr ,

I tried to remove that AND(), but the red curly line still appearing at the same spot: the "=" sign.


Hi @eka24 ,


I tried to create a dropdown, I have no idea why the "MeetingStatus" column not appearing in the list when I select

the datasource. The weird thing just crashing the entire gallery.



Helpful resources

UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

Top Solution Authors
Top Kudoed Authors
Users online (3,436)