cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
AdamH
Post Patron
Post Patron

Using gallery filter with existing search box

Hi All,

 

I have an access code app with a search bar but I also want to add a filter buttons. 

 

The code I am using at the moment for the search function is:

SortByColumns(
   Filter([@'NC Codes'], 
      StartsWith(
         'Location of Coded Lock', 
         TextSearchBox1.Text
      ) && !'Manager Code'&& !'Paramedic Code'
   ), 
   "Title", 
   If(
      SortDescending1, 
      Descending, 
      Ascending
   )
)

In my records, I have a location field called 'Locality' where we can select a location from a drop down. I have added a horizontal gallery and want to use it as filter buttons so a user can just filter the area where they are, saving them scrolling through all of the codes.

 

2021-07-18 20_02_01-Window.png

 

I'm not sure how I can integrate this with the above code so that when a user selects the 'Hunts' button, it filters the Locality Field. 

 

Can anyone help with that? 

 

 

8 REPLIES 8
Drrickryp
Super User
Super User

@AdamH 

Assuming the horizontal gallery is called Gallery1, 

 

 

With(
     {codes: SortByColumns(
                            Filter(
                                    [@'NC Codes'], StartsWith(
                                                             'Location of Coded Lock', 
                                                              TextSearchBox1.Text
                                                     ) 
                                                         && !'Manager Code'
                                                         && !'Paramedic Code'
                               ), "Title", If(
                                               SortDescending1,Descending,Ascending
                                            )
              )
       },
    },
  Filter(
         codes, Localitiy = Gallery1.Selected.Locality
  )
)

 

 

AdamH
Post Patron
Post Patron

Hi @Drrickryp 

 

Sorry I have only just round to looking at this. 

 

I tried your suggestion but I have two errors:

= and .Selected.Locality

 

2021-07-25 13_15_09-Power Apps and 2 more pages - Work - Microsoft​ Edge.png

 

Not sure if would make a difference, but the locality field is a choice field. If I delete .Locality, the only options PowerApps gives me is .Value and Label7 (I'm not sure why its showing Label7).

Drrickryp
Super User
Super User

@AdamH 

Change locality from choice to single line of text and see if it works.

@Drrickryp 

 

Unfortunately not, still only .value and .Label7 are being shown as options. 

StalinPonnusamy
Super User
Super User

Please update your filter (Combo box) and search criteria

 

Filter with Search

With(
    {sData: 'Issue tracker'},
    Search(
        Sort(
            Filter(
                sData,
                Priority.Value = ComboBox3.Selected.Value
            ),
            'Date reported',
            Descending
        ),
        TextSearchBox1.Text,
        "Title"
    )
)

 

 

@Drrickryp 

I've made some modifications - One thing I forgot about, the locality field has 'Huntingdon' selected but the button was set to 'Hunts' 

So it's now filtering but the 'All' option does not work - Will this be because locality field does not have 'All' selected along side 'Huntingdon' ?

How would I get it to display all data with using the 'All' button in Gallery1' without having to place 'All' in the locality field?

StalinPonnusamy
Super User
Super User

Hi @AdamH

 

I believe you are filtering Gallery and Locality is a choice in SP. So filter should be

 

Locality.Value = Dropdown3.Selected.Value
StalinPonnusamy
Super User
Super User

Hi @AdamH 

 

Please let us know if still any issues (s). We can help with this.

Helpful resources

Announcements
Super User 2 - 2022 Congratulations 768x460.png

Welcome Super Users

The Super User program for 2022 - Season 2 has kicked off!

Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

<
Users online (4,277)