In a recent update to Power Apps (which is undocumented at the time of writing), the Choices function now includes a second parameter that offers the ability to provide search criteria. This post explores how this updated feature works.
Demonstration of the Choices function
To highlight how the Choices function works, let's take the example of a SharePoint list of 'Property Documents'. This list includes a lookup column that is based on a 'Property' list, as the screenshot beneath shows.
If we now add a data table control and set the items property to the formula beneath, we see how the Choices function returns a list of property records. It returns two columns - id and Value. The id value corresponds to the built-in SharePoint id column.
What type of Search can we specify with the Choices function?If we now specify a search term, what type of search can does the Choices function perform and on what target fields?
The Choices function will search on the Value column. To demonstrate, we'll set the search term to "road". The intention here is to return all property records with the word "road" in the address.
The screenshot beneath shows the result. Perhaps disappointingly, it returns no records which indicates that the choice function does not apply a 'contains' type search.
When we modify the search term to search for the characters "30", the result returns all records that start with "30". This verifies that the Choices function performs a "starts with" search on the search criteria.
It's now possible to specify a search term when we call the Choices function. This will return only those records that start with the specified search value. This feature enables us to more easily filter the results from Choices function, compared to the traditional method of wrapping a call to Choices inside a call to Filter.