How to Use Power Apps Search Function + 6 Various Examples

Recently, I created an application in Power Apps for internal employees to store their information. There, I was required to search for employees by department name and job title. Fortunately, the Power Apps Search function helped me achieve this requirement.

In this tutorial, I will explain the Power Apps Search function using syntax and some examples by taking simple scenarios.

Let’s get started with the search function syntax!

Power Apps Search Function

In Power Apps, we can use the search function to find records from a data table that contains a string value in any of the columns. The search string can be presented anywhere in the columns.

The search function matches using a single string instead of a formula. The table should contain columns with a Text, a String value.

It will not take any column value other than a text value, such as a Number, Choice, Picture, Hyperlink, etc. A Lookup column does not work with the Power Apps search function.

Power Apps Search Syntax

Search( Table, SearchString, Column1 [, Column2, ... ] )

Where,

  • Table = It specifies the Table name that is used to search
  • SearchString = We can specify the string to search for. If there is a blank or empty string, it will be returned to all the records
  • Column = Specify the column names you want to search from the table

Search Power Apps Collection Values

Now, look at this small example of how we can use the search function on the Power Apps collection.

Here, I have a Power Apps collection named “colEmployee,” with some records. Refer to the code below.

ClearCollect(colEmployee,
    {
        EmployeeID: "SP001",
        EmployeeName: "Johannal",
        Department: "IT"
    },
    {
        EmployeeID: "SP002",
        EmployeeName: "Lynee",
        Department: "Sales"
    },
    {
        EmployeeID: "SP003",
        EmployeeName: "Henritta",
        Department: "IT"
    },
    {
        EmployeeID: "SP004",
        EmployeeName: "Lidia",
        Department: "Sales"
    },
    {
        EmployeeID: "SP005",
        EmployeeName: "Patti",
        Department: "IT"
    }
)

Where,

  • colEmployee = Power Apps collection name
search in power apps

I want to search the collection column string value [IT] and display the search results on the Data table control. To do so, follow the below steps. Such as:

1. On the Power Apps screen, insert a Data table and set its Items property to the code below.

Items = Search(
    colEmployee,
    "IT",
    Department
)

Where,

  • colEmployee = Collection name
  • “IT” = String/Text value
  • Department = Collection column name
search in powerapps

2. To display the collection fields on the data table, click on the Edit fields option, select the + Add fields option to choose respective fields, and click the Add button, as shown below.

powerapps search function

3. Finally, save, publish, and preview the app. The data table displays search results based on the specific string value of the department column [IT]. The output is shown in the screenshot below.

Output:

power app search function

Then, we will see another example of using the Power Apps search function.

Search Power Apps Gallery Items Using Collection

Here, I created a Power Apps application that contains the employee details [colEmployee] in a gallery. I also have a search bar. Now, I need to get the employee details of the department value I entered in the search bar.

Like in the image below.

search function power apps

To work around this, follow the steps below.

1. Insert a Text input and a Gallery control on the Power Apps Screen, and set its Items property to the code below.

Items = Search(
    colEmployee,
    txt_Department.Value,
    Department
)

Where,

  • txt_Department = Text input control name
power apps search gallery

2. Now, Preview the app. The gallery displays search results once users search for any department value on the text input control. This is how we can work with the Power Apps search function on the gallery.

Search Power Apps Gallery Items Using SharePoint List

Now, we’ll see how to search Power Apps gallery items by taking the SharePoint list as a datasource. Here, I have a SharePoint Online list named “Vacation Budget,” which contains the fields below.

Column NameData Type
DestinationIt is a default single line of text
Expense NameA single line of text
CategoryChoice
Total CostNumber
Power Apps Search Function Sharepoint List

I would like to display these list records on the Power Apps gallery control based on the Destination value [Spain]. To do so, follow the below steps.

1. On the Power Apps Screen, insert a Gallery control and set its Items property as:

Items = Search(
    'Vacation Budget',
    "Spain",
    Title
)

This formula will search the “Spain” string details in the gallery.

search in gallery powerapps

2. The gallery control displays search results once you preview the app, as shown below.

search powerapps

Let’s see how to handle delegation warnings while working with the search function in Power Apps.

Power Apps Search Function Delegation Warning

Note:

When the data in the data source exceeds 500 records, and a function can’t be delegated, the Power Apps may not be able to access it and may give the wrong results.
Power Apps Search Function Delegation Warning

To overcome this issue, you must create a collection [colVacations] using the SharePoint Online list. Select the App object and set its OnStart property to the code below.

OnStart = ClearCollect(
    colVacations,
    'Vacation Budget'
)

Where,

  • colVacations = Power Apps collection
  • ‘Vacation Budget’ = SharePoint Online list
search syntax in powerapps

Select the gallery control and set its Items property to the code below.

Items = Search(
    colVacations,
    "Spain",
    Title
)
powerapps search

This is how we can work with the Power Apps search function delegation warning.

Display Multiple Field Values While Searching in Power Apps Gallery

Up to now, we have seen the search function display only a single field value. Now, I will explain how to display multiple field values while searching for one item in the gallery.

Here, I have a gallery that contains destination and expense names. When you search for expense items, their related destination and other expense names are displayed, as in the example below.

search function powerapps

To work around this, follow the steps below. Such as:

1. On the Power Apps Screen, insert a Gallery control and set its Items property to the code below.

Items = Search(
    colVacations,
    txt_MultipleSearch.Text,
    Title,
    'Expense Name'
)

Where,

  • txt_MultipleSearch = Text input control name
  • Title, ‘Expense Name’ = SharePoint list fields
Power Apps Search Function Multiple Conditions

2. Now, Preview the app. When the user searches for any value from the Sharepoint list filed value, the gallery will display search results from multiple fields.

Let’s see how to work with the combined Power Apps search and filter functions.

Power Apps Search and Filter Combined

I have a Power Apps collection [colEmployee], and I would like to search for employees by EmployeeID and filter them by Department. The output is shown in the screenshot below.

Power Apps Search and Filter Combined

To achieve it, follow the below steps. Such as:

1. On the Power Apps Screen, insert a Text input for search EmployeeID, add a Dropdown, and set its Items property.

Items = ["IT", "HR", "Sales", "Marketing"]
search function in power apps

2. Now, insert a Gallery control and set its Items property to the code below.

Items = Search(
    Filter(
        colEmployee,
        Department = drp_EmpDepartment.Selected.Value
    ),
    Text(txt_EmpID.Value),
    EmployeeID
)

Where,

  • drp_EmpDepartment = Dropdown control name
  • txt_EmpID = Text input control name
  • Department, EmployeeID = Collection fields
search powerapps gallery

3. Finally, once the user searches EmployeeID from the text input and filters the Department value from the dropdown control, the gallery will display search and filter records, as shown below.

search function in powerapps gallery

This is how we can work with the combined Power Apps search and filter functions.

Also, you may like:

I hope you found this article helpful. You reference this article while working with the Power Apps search function on the Data table, Gallery, or Collection.

  • Hi,
    it’s great work.
    I want to a help about search box of power app which will work like, if I write any word in search box, and it is available in list or column so result shows it valid, if this search word is not available in the column then result shows invalid.
    can you please help me in this regard,
    Thanks in advance

  • This formula you provided just fixed my entire App. I couldn’t get the search and combo box to work together properly, as most instructions seem to only use filter instead of filter and search. Thank you! Items = Search(
    Filter(
    colEmployee,
    Department = drp_EmpDepartment.Selected.Value
    ),
    Text(txt_EmpID.Value),
    EmployeeID
    )

  • >