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

Filtering gallery by another gallery and search box

Hi


Apologies as I am new to PowerApps. 

 

I have created a directory app where I would like to filter information by clickable titles (using Gallery1) and also by the search box (see screenshot).

 

I have 2 galleries in my app, Gallery1 with the headings to filter the information by and BrowseGallery1 that shows the filtered information.

 

I have managed to filter my information in BrowseGallery1 using the headings in Gallery1 through this code:

SortByColumns( Filter (Main_Staff,StartsWith(Type,Gallery1.Selected.Result)),"Type",If(SortDescending1,Descending,Ascending ))

 

How am I able to filter the information by using a search box as well? I have had a look online but as a newbie I am usure what code to type to link up the search box as well. 

 

Any help would be appreciated.

 

1 ACCEPTED SOLUTION

Accepted Solutions
Community Support Team
Community Support Team

Re: Filtering gallery by another gallery and search box

Hi @G90PAPP,

 

Please take a try to set the Items property of the BrowserGallery1 control to following formula:

If(
IsBlank(TextSearchBox1.Text),
SortByColumns(
        Filter(
           Main_Staff,
           StartsWith(Type,Gallery1.Selected.Result),
          ),
     "Type",
      If(SortDescending1,Descending,Ascending)
),
SortByColumns(
        Search(
           Main_Staff,
           TextSearchBox1.Text,
           "Name",
           "Email",
           "Department",
           "Section",
           "Evidence",
           "Type"
          ),
     "Type",
      If(SortDescending1,Descending,Ascending)
)
)

Please check the above solution that I provided, then check if the issue is solved.

 

Best regards,

Kris

 

Community Support Team _ Kris Dai
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

5 REPLIES 5
Super User
Super User

Re: Filtering gallery by another gallery and search box

The Filter() allow for multiple condition and they are treated as an "AND" operator. The example below will return the items where the Type field starts with the Gallery1.Selected.Result AND 'Field Name' starts with what is in the search box. If the search box is blank it should return the items that met the first condition.

 

 

SortByColumns(
    Filter ( Main_Staff ,
        StartsWith(
            Type,
            Gallery1.Selected.Result
        ),
        StartsWith(
            'Name of field to search',
            TextSearchBox1.Text
        )
    ),
    "Type",
    If(
        SortDescending1,
        Descending,
        Ascending
    )
)

 



--------------------------------------------------------------------------------
If this post helps answer your question, please click on “Accept as Solution” to help other members find it more quickly. If you thought this post was helpful, please give it a Thumbs Up.
Community Support Team
Community Support Team

Re: Filtering gallery by another gallery and search box

Hi @G90PAPP,

 

Do you want to filter your information within your BrowserGallery1 control based on the Searchbox value?

 

I agree with @Jeff_Thorpe's thought almost. I assume that there is a search field within your data source, which you want to search based on the SearchBox value.

 

I have made a test on my side, please take a try to modify your formula within the Items property of the BrowserGallery1 control as below:

 

SortByColumns(
Filter(
Main_Staff,
StartsWith(Type,Gallery1.Selected.Result),
StartsWith("SearchFieldInYourDataSource",TextSearchBox1.Text)
),
"Type",
If(SortDescending1,Descending,Ascending)
)

or

 

 

SortByColumns(
        Filter(
           Main_Staff,
           StartsWith(Type,Gallery1.Selected.Result),
           TextSearchBox1.Text in "SearchFieldInYourDataSource"
          ),
     "Type",
      If(SortDescending1,Descending,Ascending)
)

Note: The TextSearchBox1 represents the SearchBox (Text input control) within your app.

 

More details about the Filter function in PowerApps, please check the following article:

Filter function

 

Best regards,

Kris

 

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
G90PAPP
Level: Powered On

Re: Filtering gallery by another gallery and search box

Hi 

 

 

 

 

Community Support Team
Community Support Team

Re: Filtering gallery by another gallery and search box

Hi @G90PAPP,

 

Please take a try to set the Items property of the BrowserGallery1 control to following formula:

If(
IsBlank(TextSearchBox1.Text),
SortByColumns(
        Filter(
           Main_Staff,
           StartsWith(Type,Gallery1.Selected.Result),
          ),
     "Type",
      If(SortDescending1,Descending,Ascending)
),
SortByColumns(
        Search(
           Main_Staff,
           TextSearchBox1.Text,
           "Name",
           "Email",
           "Department",
           "Section",
           "Evidence",
           "Type"
          ),
     "Type",
      If(SortDescending1,Descending,Ascending)
)
)

Please check the above solution that I provided, then check if the issue is solved.

 

Best regards,

Kris

 

Community Support Team _ Kris Dai
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

G90PAPP
Level: Powered On

Re: Filtering gallery by another gallery and search box

Hi @v-xida-msft

 

It works! Thank you very much. 

Helpful resources

Announcements
thirdimage

Power Apps Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Power Platform World Tour

Find out where you can attend!

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

SecondImage

Difinity Conference

The largest Power BI, Power Platform, and Data conference in New Zealand

Top Solution Authors
Top Kudoed Authors (Last 30 Days)
Users online (6,098)