Filtering data in PowerApps using Search and Tags

Isaac Stephens, 15 May 2019

It is easy to search for an item in PowerApps with the built in Search() function by simply setting the Items attribute in your Gallery to Search(source, textbox.txt) as shown in the image below.

image

However, this only looks for that exact sequence of characters/words. Sometimes you will want to search for something that isn’t in sequence, such as an item called ‘Meeting room for students’ and you may search ‘student meeting room’. If you used the Search() function you would not find your item.
 
To do this, you need to use a slightly more complex formula that adds a new column to the Data Source. This column represents the amount of times the item is found by each word in your search box, for example if you search ‘student meeting room’ the item called ‘Meeting room for students’ will have a ‘found’ value of 4 as each of the keywords in the search were in the item's name. It does this by splitting the text by spaces and then checking if each result of Split() is in the display name, if it is then 1 is added to the new column. The Data Source is then filtered depending on whether the ‘found’ value is greater or equal to the number of strings returned in the split function.

image

An additional requirement you may have is to filter via predefined tags from a combo box. One way to do this is to just append the selected tags to the search text in the previous function as shown below.

image 
In both examples you will note that Lower() is used on both the Result and the ‘Display Name’ this is so that the search is not case-sensitive, it is not required but does mean that users won’t need to worry about using the proper case.