cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
dmowry
Level: Powered On

Filter a gallery by a radio button

I'm really new to this powerapps thing and I would think doing a filter on a gallery based on a radio button would be as simple as... 

 

Filter(source,radio1.selected.result in column)

 

However, the more i'm reading on similar people posting the same question, I dont think that's the case. Here is what I have, I have a text area that is applying filters to Gallery1. I also have two radio buttons and a combo box I also want to apply filters to Gallery1. 

 

I have my text box filtering correctly, but I cannot seem to link up the either radio buttons or combo box. Combo Box excluded, how can I link up the radio buttons with the gallery? Also, can i make the radio buttons contextually aware of the results in the gallery? 

 

Thanks,

1 ACCEPTED SOLUTION

Accepted Solutions
v-yutliu-msft
Level 10

Re: Filter a gallery by a radio button

Hi @dmowry ,

Could you show me your formulas?

I suggest you use the IsBlank function to justify the conditions.

Try formula like this:

If(
    IsBlank(searchbox.Text)&&IsBlank(Radio1.SelectedText.Value),table
    IsBlank(searchbox.Text)&&!IsBlank(Radio1.SelectedText.Value),
        Filter(table,field1=Radio1.SelectedText.Value,field2=Radio2.SelectedText.Value,....) 
    !IsBlank(searchbox.Text)&&IsBlank(Radio1.SelectedText.Value),
         Search(table,searchbox.Text,field1,field2,...),
     !IsBlank(searchbox.Text)&&!IsBlank(Radio1.SelectedText.Value),
          Filter(table,searchbox.Text in field1||searchbox.Text in field2||...,field1=Radio1.SelectedText.Value,field2=Radio2.SelectedText.Value,....)
      )

 

 

Best regards,

Community Support Team _ Phoebe Liu

15 REPLIES 15
myke_deabreu
Level 8

Re: Filter a gallery by a radio button

Hi Dmowry,

 

You can do it two ways:

 

First Method (I use this method most times):

 

Use the OnChange of the radio button to assign a varible on the Text you want to filter.

 

E.G.: If(Radio1_1.SelectedText.Value="Blue",Set(varname,"Blue"),If(Radio1_1.SelectedText.Value="Red",Set(varname,"Red")))

 

Then Set your gallery to Filter(datasource,column=varname) or Filter(datasource,column in varname)

Second Method:

 

Filter(Datasource,column in radio1.selected.value) or Filter(Datasource, column = radio1.selected.value)

 

Not sure if I misunderstood your question - if so can you let me know.

dmowry
Level: Powered On

Re: Filter a gallery by a radio button

I tried both ways and same results, selecting values in the radio button list does not change the gallery list. 

 

My OnChange event: 

If(Radio1.SelectedText.Value = "Dessert",Set(varname,"Dessert"),If(Radio1.SelectedText.Value="Main Dish",Set(varname,"Main Dish"),If(Radio1.SelectedText.Value="Side Dish",Set(varname,"Side Dish"))))

 

My Items event on the Gallery: 

SortByColumns(
Filter('VAI Recipes', TextInput1.Text in Title ||
TextInput1.Text in Ingredients ||
TextInput1.Text in 'Created By'.DisplayName ||
TextInput1.Text in 'Dietary Restrictions'.Value ||
TextInput1.Text in 'Type of dish'.Value ||
varname in 'Type of dish'.Value),
"Title", If(SortDescending1, Ascending, Descending))

 

The alternate way you suggested, did the same, filtering on the gallery didn't work. 

 

The field I'm attempting to filter on is not a single line text field, but rather a drop down field. Does that  have an impact on what i'm trying to do?

myke_deabreu
Level 8

Re: Filter a gallery by a radio button

What do you mean its a dropdown list.

 

Are you wanting your dropdown list to change based on the radio button?

dmowry
Level: Powered On

Re: Filter a gallery by a radio button

My source is coming from a drop down list and not a single line text. Not sure if that mattered with what i'm trying to do.

myke_deabreu
Level 8

Re: Filter a gallery by a radio button

so 'Vai Recipes' is the dropdown control name?

 

If you are able to take a screenshot may give some more context.

dmowry
Level: Powered On

Re: Filter a gallery by a radio button

VAI Recipes is the SharePoint list (data source)

myke_deabreu
Level 8

Re: Filter a gallery by a radio button

Are any of the filters working?

When you said the dropdown is the source what did you mean by that?

 

Looking at your formula I dont see a problem. Only thing is I have never seen arguments seperated with "||" but rather ",".

 

Are you getting delegation warnings on this formula? Also, how many items are in the Sharepoint list?

dmowry
Level: Powered On

Re: Filter a gallery by a radio button

Yes, the text input is working and filtering correctly. 

Attached is my form the user will be filling out, as you can see Type of Dish and Serves are drop downs. Dietary Restrictions is a multi select drop down. 

 

The || is an OR statment rather than an AND statment (which is what the comma is).  

 

I do get the delegation warnings because in the filter i'm using IN with filter. However, my list currently has 5 items in it. 

myke_deabreu
Level 8

Re: Filter a gallery by a radio button

oh so there is no radio button.

 

Try this:

 

SortByColumns(
Filter('VAI Recipes', TextInput1.Text in Title ||
TextInput1.Text in Ingredients ||
TextInput1.Text in 'Created By'.DisplayName ||
TextInput1.Text in 'Dietary Restrictions'.Value ||
TextInput1.Text in 'Type of dish'.Value ||
Dropdown2.SelectedText.Value in 'Type of dish'.Value),
"Title", If(SortDescending1, Ascending, Descending))