When working with the Power Apps Search function, we often faced an error like “The function Search has some invalid arguments.
To resolve this issue, follow this Power Apps tutorial to get the information with a simple scenario. Also, I will discuss how to overcome the delegation warning of the Search function [Delegation warning. The “Search” part of this formula might not work on large data sets]
Search invalid argument type Power Apps
In Power Apps, the Search function is used to find records in a data source [SharePoint, Excel, etc.] that match one or more criteria. It’s commonly used with galleries or data tables to filter and display specific data based on user selections.
Syntax of the Power Apps Search function:
Search(DataSource, SearchBox.Text, [column1, column2, ...])
Where,
- DataSource = We can use different data sources to find records
- SearchBox = Normally, we can use Text input control as a search box
- column1, column2, … = Data source filed names
Let’s take a simple scenario: I have a SharePoint Online list named “Travel Requests,” which contains the fields below.
Column Name | Data Type |
Trip Title | It is a default single line of text |
Destination | Location |
Airline | Choice |
Requested By | Person or Group |
Approved | Yes/No |
Travel Start Date | Date and time |
In Power Apps, there is a Text input control to search the records and a Data table control to display the SharePoint list records based on the search value.
To search and display SharePoint list records on the Power Apps data table, I will use the formula below on the Data table’s Items property.
Items = Search('Travel Requests',txt_Search.Text,"Title","Destination", "Airline")
Where,
- ‘Travel Requests’ = SharePoint Online list
- txt_Search = Power Apps text input control name
- “Title” = SharePoint list text field
- “Destination” = SharePoint list person field
- “Airline” = SharePoint list choice field
When I was using the above formula, that time I was getting an error message: “The function ‘Search’ has some invalid arguments”, as shown below.
The main issue in the above formula is that I have used a Location column [Destination] and a Choice column [Airline], which does not support this Search function.
Note:
The Power Apps Search function only supports “Text Fields” [Single line of text and Multiple lines of text].
Now, we will check whether the Power Apps Search function supports Text fields. For that, I have used the below formula on the Data table’s Items property.
Items = Search(
'Travel Requests',
txt_Search.Text,
"Title",
"Description"
)
Where,
- “Title”, “Description” = SharePoint list text fields
When I implemented this above correct formula, then the error was solved, and it was working perfectly for me.
However, the search function will give the Delegation warning [Delegation warning. The “Search” part of this formula might not work on large data sets], as shown below.
To overcome this, we should create a collection using a SharePoint list. To do that, select the App object and set its OnStart property to the code below.
OnStart = ClearCollect(
colTravel,
'Travel Requests'
)
Where,
- colTravel = Power Apps collection name
And, finally select the Data table control and set its Items property to the code below.
Items = Search(
colTravel,
txt_Search.Text,
"Title",
"Description"
)
Once your app is ready, Save, Publish, Run OnStart, and Preview the app. Whenever the user searches the SharePoint list recorded on the text input control based on the Title or Description value, the data table finds and displays the records based on the search value.
Have a look at the below screenshot for the output.
This is how we can work with the function search has some invalid arguments in Power Apps.
Important Points to Remember in Power Apps Search Function
Below are some important points that you have to remember while using the Power Apps Search Function. So that it may help you resolve this above type of error in your apps:
- If you are using the Data source as an Excel Sheet and there is a space between the column name as “Employee Name, “then the column name should be “Employee_x0020_Name” in the formula. (Here, each space is specified as “_x0020_“)
- Similarly, if you are using a Data source like SharePoint, make sure that you have passed the internal name of the specific column or the column name should be the same as the SharePoint List column name.
- You do not pass the misspelled column name. If your column name is “Heading, ” do not pass the column name as “heading; otherwise, you will face this type of issue.
- Another important thing is that whatever column you are passing should be a Text column. If not, you will face this issue.
- You may get the error if you use “;” instead of the normal comma “,” in the Search function formula.
I hope this Power Apps tutorial is helpful; if you are facing any issues related to the Power Apps Search function, you can follow this post to get an idea of how to resolve them.
Some more Power Apps articles you may also like:
- Create Power Apps Quiz App
- Create Power Apps Login Page
- Filter Gallery in Power Apps
- Power Apps Upload File to SharePoint Document Library
- Create CSV File in SharePoint Using Power Apps
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
Thanks for clarifying