cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
AdamH
Helper V
Helper V

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
Helper V
Helper V

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
Community Champion
Community Champion

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"
    )
)

 

 


Thanks,
Stalin

Learn To Illuminate

@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
Community Champion
Community Champion

Hi @AdamH

 

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

 

Locality.Value = Dropdown3.Selected.Value

Thanks,
Stalin

Learn To Illuminate
StalinPonnusamy
Community Champion
Community Champion

Hi @AdamH 

 

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


Thanks,
Stalin

Learn To Illuminate

Helpful resources

Announcements
PA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

Welcome Super Users.jpg

Super User Season 2

Congratulations, the new Super User Season 2 for 2021 has started!

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

Top Solution Authors
Top Kudoed Authors
Users online (1,029)