The Function Search Has Some Invalid Arguments in Power Apps

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 NameData Type
Trip TitleIt is a default single line of text
DestinationLocation
AirlineChoice
Requested ByPerson or Group
ApprovedYes/No
Travel Start DateDate and time
the function choices has invalid arguments

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.

invalid argument type powerapps

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
See also  PowerApps Search User

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 second argument to the left function is invalid

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.

the function search has some invalid arguments powerapps

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.

the function run has some invalid arguments

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
powerapps invalid argument type

And, finally select the Data table control and set its Items property to the code below.

Items = Search(
    colTravel,
    txt_Search.Text,
    "Title",
    "Description"
)
invalid argument type expecting one of the following powerapps

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.

See also  Power Apps Modern Controls

Have a look at the below screenshot for the output.

invalid argument type expecting a text value instead

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.

See also  How to Delete Rows in Power Apps Data Table?

Some more Power Apps articles you may also like:

  • >