6 Various Power Apps Search Function Examples

As a Power Apps developer, you should learn all the functions to build more attractive and responsive applications. Apart from that, the Search function helps to find records from a table that contains a string value in any of the columns.

In this tutorial, I will explain the Power Apps Search function and its syntax. Also, by taking some simple scenarios, we will cover the topics below related to the Power Apps Search Function. Such as:

  • Power Apps Search Gallery
  • Power Apps Search Function Sharepoint List
  • Power Apps Search Function Delegation Warning
  • Power Apps Search Function Multiple Conditions
  • Power Apps Search and Filter Combined

Power Apps Search Function

In Power Apps, we can use the Search function to find records from a 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 or 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
See also  Power Apps Dataverse Yes/No Field

Power Apps Search Function Example

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

Power Apps Search Gallery

In this example, I will explain how to work with the Power Apps search gallery using the Power Apps collection [colEmployee] based on the search box value. To work around this, follow the below-mentioned steps.

1. On the Power Apps Screen, Insert a Text input and a Gallery control, 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. Once users search any department value on the text input control, the gallery displays will display search results, as shown below.

See also  How to Use Power Apps Modern Combobox Control?

Output:

search function power apps

This is how we can work with the Power Apps search gallery.

Power Apps Search Function Sharepoint List

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

Now, 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
)
search in gallery powerapps

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

search powerapps

Power Apps Search Function Delegation Warning

Have a look at the screenshot below. A delegation warning will be visible at the top of the gallery [Delegation warning. The “Search” part of this formula might not work currently on large data sets].

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 can create a collection [colVacations] using the SharePoint Online list. For that, 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

Now, 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.

Power Apps Search Function Multiple Conditions

Let’s see how to work with the Power Apps Search function multiple conditions with a simple scenario.

See also  People Picker in Power Apps

Scenario:

Suppose you want to search multiple conditions [By Destination and Expense Name] using the Search function in Power Apps.

To work around this, follow the below-mentioned steps. 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 based on multiple conditions.

Output:

search function powerapps

This way, we can display search results based on multiple conditions.

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 Power Apps Search and Filter combined.

Also, you may like:

  • 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

  • >