The Power Apps Filter and StartsWith functions are very flexible and can be used to search single or multiple columns in a table

In this article I’ll show how to give users the option to choose which columns to search

Filter and StartsWith Functions

In the demo below, the user can decide whether to use the Country or Continent columns for their search via a Radio Button.  This approach gives the option to drill down into the data to find a particular record, or if the user already knows what they are looking for, they can quickly cut through the mass of data

filter and startswith

Below is the code assigned to the Items property of the Gallery

SortByColumns(
If(
Radio.Selected.Value = "Country",
Filter(
Country,
StartsWith(
Title,
TextInput_Search.Text
)
),
Filter(
Country,
StartsWith(
Continent,
TextInput_Search.Text
)
)
),
"Continent",
Ascending,
"Title",
Ascending
)

The If statement identifies which of the Radio Buttons has been selected and then uses the Filter and StartsWith functions on the selected column.  SortByColumns sorts the filtered data first by the Continent column and then by Country 

Alternatives and Further Options

Check Boxes could be used instead of a Radio Button to allow both columns to be used in the search, or more columns to be selected

The Search function could also be used instead of StartsWith to search within the full text of fields, rather than just at the start

This technique could also be combined with the cascading Dropdown Boxes described here to provide a really sophisticated search capability 

More Info

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top