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
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
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.
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:
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.
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
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 Name | Data Type |
Destination | It is a default single line of text |
Expense Name | A single line of text |
Category | Choice |
Total Cost | Number |
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.
2. The gallery control displays search results once you preview the app, as shown below.
Let’s see how to handle delegation warnings while working with the search function in Power Apps.
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. This formula’s “Search” part 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.
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
Select the gallery control and set its Items property to the code below.
Items = Search(
colVacations,
"Spain",
Title
)
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.
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
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.
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"]
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
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.
This is how we can work with the combined Power Apps search and filter functions.
Also, you may like:
- How to Use Power Apps Find Function
- Bind SharePoint Lookup Column in Power Apps Dropdown
- Create SharePoint List & Add Columns Using PnP PowerShell
- How to Solve Power Apps Search Function Invalid Argument Issue
- Power Apps Sort Gallery Examples
- Power Apps Search SharePoint List Examples
- Power Apps StartsWith and EndsWith Functions
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.
I am Bijay a Microsoft MVP (10 times – My MVP Profile) in SharePoint and have more than 17 years of expertise in SharePoint Online Office 365, SharePoint subscription edition, and SharePoint 2019/2016/2013. Currently working in my own venture TSInfo Technologies a SharePoint development, consulting, and training company. I also run the popular SharePoint website EnjoySharePoint.com
Great rundown, thanks, Billy…
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
)