Updated: May 21
The PowerApps filter function allows you to build and implement a search box capable of dynamic data filtration. Using PowerApps, you can filter through data tables and look for specific records that satisfy a set criteria.
Use this guide to learn the nuances of the PowerApps Filter and build a custom PowerApps Gallery - or follow along with Shane!
Creating a Basic Gallery Layout
Begin by clicking ‘Apps’ in the left pane and then ‘Create an App’ at the top left of the new window. You should be looking at a new window. Select the blank tablet layout at the bottom of the list.
You will see a window asking you to go through a tutorial. Feel free to skip it at this point.
To generate data in the gallery, first click ‘Gallery’ in the top ribbon and then select a data source from the available list. The data will populate the new gallery. Change the layout to ‘Title and subtitle’ and select ‘Title’ in the dropdown menu for ‘Title2.’
You should now have a simple gallery layout.
Building Your First Filter function
To use the PowerApps filter function:
Click on ‘Text’ in the top ribbon and then select ‘Text input’ from the dropdown menu. Move the new text box to your desired location.
Remove the default text from the command input at the top. Change the type in the box to the left from ‘Default’ to ‘HintText.’ This will allow you to input a hint into the text box to help the user understand the expected input.
Rename the box ‘FilterTextBox.’
Make sure you have your gallery selected in the left pane. The screen should currently be populated by ‘EmployeeDetails.’
Highlight the text in the command bar at the top and change it to ‘Filter(EmployeeDetails, FilterTextbox.Text = Title).’
Now, try typing a name from the data source. It should bring up the expected title for the name.
Using Operators in Your Functions
Try changing the ‘=’ in the function to ‘in’ so you have ‘Filter(EmployeeDetails, FilterTextbox.Text in Title).’ Now, the name will show up dynamically so long as the text being typed still matches the title.
Next, change the function to ‘Filter(EmployeeDetails, StartsWith(Title, FilterTextBox.Text)).’ With this filter function, the names all show up at the start and are then filtered out as you type your selection. There are many operators you can use to give you an enhanced experience.
Understanding How the Operators Work
The operator is an essential component that makes PowerApps filters work. This comes with a downside, though. If you look at the ‘in’ that was added to the function, it will have a small warning line beneath it. This indicates that the data will have to be processed on the client’s side. This can be a big deal if large amounts of information are being processed and the local computer cannot handle the load.
Filters allow you to delegate the processing of data between the server and host machine. You have to be specific about which operators are used in the function so that you have a grasp of where the data is being processed.
Microsoft documents each operator and how it works on the PowerApps website.
Appending Logical Text in Filter Functions
You can append the function with more logical text.
Change the filter to ‘Filter(EmployeeDetails, StartsWith(Title, FilterTextBox.Text).FavoriteColor = “Red”).’ This filter will show only those with the color “Red” set as their favorite color in the database.
The logical text allows you to use multiple conditions to filter your data with the PowerApps filter function. This is an important concept for building effective applications. By utilizing filter functions, you can create apps that easily guide users through large amounts of data.
Filtering Through the Imported Data
To create a look-up column to find specific data points type ‘Filter(EmployeeDetails, FilterTextbox.Text = Look.Value)’ into the function box. This will work, but you will see that there are a few flags highlighted in the function.
A cleaner approach would be to look up more specific values with ‘Filter(EmployeeDetails, FilterTextbox.Text = Title).’ This is more specific and allows you to import your data more efficiently.
Creating Nested Galleries with Filter Functions
Nested galleries are an effective way to control your data input on the fly:
Create a new screen with a vertical gallery and import your data source.
Once it connects, change your layout to ‘Title and subtitle’ and select ‘Title’ below that. Your gallery should be populated by the data that was imported.
Select another vertical gallery from the top ribbon and add another data source associated with the first by typing ‘Filter(ProjectTasks, Project = Gallery2.Selected.ProjectName).’
You can nest your galleries to be sequentially generated once the user has selected an option. This will let you dig deeper into the data by providing branches to the application, allowing you to create more complex applications.
Learning the Mechanics of Filter Functions
Learning to use the PowerApps filter function will help you understand the basic mechanics of data processing.
Understanding delegation and the use of operators is essential for effectively managing large batches of information. This is why the filter function is such an important part of PowerApps.