Filter Power Apps: How to filter data in business apps

Power Apps' Filter is a pillar of Microsoft's low-code ecosystem. This functionality gives users the ability to immediately find the information they are looking for, filtering large volumes of data within business applications. In this article, we'll dive into what Power Apps' Filter feature is and how to use the Filter feature. We'll also see a useful use case for managing information in a customer management app.

What you'll find in this article

  • Filter Power Apps: a brief introduction
  • How Power Apps Filter works
  • Syntax and parameters of the Power Apps Filter function
  • Filter Power Apps: How to use it?
  • Filter Power Apps: Use Cases and Practical Examples
  • Filter Power Apps: the most common mistakes to avoid
  • Tips for using Power Apps' Filter
  • Filter Power Apps in a customer management app
Filter Power Apps: How to filter data in business apps

Filter Power Apps: a brief introduction

The Filter function of Microsoft Power Apps is by far one of the most important functions within the low-code development environment offered by Microsoft and plays a crucial role in helping users work with large volumes of data.

It allows you to search through tables and locate records that match specific criteria, making it easier to find the information you need quickly, efficiently and easily.

The Filter function works by examining the records in a table and verifying them against one or more set formulas. When records meet the specified criteria, they are included in the output, and those that don't are discarded. In this way, you can efficiently reduce search times on large data sets, focusing on the records that are most relevant to your needs.

With the filtering function, Power Apps applications can become more dynamic and user-friendly, and using this versatile tool you can greatly simplify browsing through your data, allowing users to find what they need with a minimum of effort and frustration.

How Power Apps Filter works

The Filter function in Power Apps plays a critical role in refining and narrowing the results of a data search displayed in your app, allowing you to find records in a table that meet specific criteria and ensuring that only relevant information is shown to users. This feature simplifies data management, saving valuable time and effort for your employees and users.

When you use the Filter function, you provide a table and a formula that define the conditions that each record must meet in order to be displayed. The function will then evaluate each record in the table, including only those that meet the given criteria and discarding the rest.

A filter function does the same things that the search function would do (which essentially takes a table, a search string and the columns in which you want to search) and adds a whole series of very important elements to maximize the refinement of the search process within the data sources that interest us.

Using the search function, all this function does is take the specific search term and check the given columns within the table to see if there is a match.

Instead, when we use the Filter function, it takes the conditional logic and compares it with each row in the table. If the function finds a record that meets the conditions given above, it returns that record.

The result is a new table with filtered data, which can be used in other components, such as galleries or forms, within your app.

Some practical examples of using the filter function in Power Apps include:

  • Find projects with a specific status
  • View meetings scheduled for the current day
  • Show employees from a certain department
  • Show customers by subscription type

To ensure the best performance and delegation support, it is important to pay attention to the size of the selected data sets when using the filtering function. Delegation is critical when working with large sets of data, as it allows you to filter on the data source instead of loading all the records into the app.

Syntax and parameters of the Power Apps Filter function

The Filter function in Power Apps allows us to filter the records in a table based on one or more criteria specified by a formula. The general syntax of this particular formula should look something like this:

Filter (Table, Formula 1 [, Formula 2,...])

This function evaluates each record in the specified table and keeps only those records that meet the criteria specified in the formula (s).

In this syntax, 'Table' represents the data source, and 'Formula 1' and 'Formula 2' define the conditions that must be met for a record to be included. It is possible to use multiple formulas, separated by commas, to add complexity and specificity to the filtering criteria that we want to include in our search.

The filter function has the following parameters:

  • Table: The table that you want to filter. This parameter is required.
  • Formula 1: The first formula to apply to the table. This expression evaluates each record in the table to determine if it meets the filter criteria. This parameter is required.
  • Formula2,...: Optional additional formulas, separated by commas, for further refinement and restriction of the filter result. These parameters are, unlike the previous one, optional.

When using the filtering function, it is essential to understand how the various parameters that help produce the final filtered result interact with each other. The more formulas you specify, the more defined and refined the result of your research will be.

Filter Power Apps: How to use it?

Having made a general overview of how the Filter function of Microsoft Power Apps works, let's see together how to use it effectively, based on single or multiple criteria and with logical operators.

Filtering based on a single criteria

When filtering data from SharePoint or other sources based on a single criterion, you only need to provide the table and the condition that you want to verify. For example, if you have a table with the data of your employees and you want to view those with an annual salary greater than 10,000, we can write:

Filter (EmployeeTable, AnnualSalary > 10000)

This formula will return a set of records from the table of employees that meet the given condition (in this case 'Salary > 10000').

Filtering based on multiple criteria

Often it will be necessary to filter the data that you want to analyze based on multiple criteria. In these types of cases, it is possible to extend the filtering function with additional conditions. Going back to our previous example, to search for employees with an annual salary between 10,000 and 30,000, you can write:

Filter (EmployeeTable, AnnualSalary > 10000, Salary < 30000)

This formula will automatically return us all the records from the employee table that meet the two conditions specified in it.

Filtering with logical operators

The Filter function of Microsoft Power Apps also allows us to use logical operators such as' and 'or' or 'to increase the specificity of our searches. Let's take a look at how we can use the two operators mentioned above for our data filtering needs.

If we wanted to use the 'and' operator, we just need to write each condition as a separate argument within the filter function, as in the example proposed below:

Filter (EmployeeTable, AnnualSalary > 10000, Department = “Accounting”)

This formula will return employees with an annual salary of more than 10,000 and who belong to the accounting department (here indicated with the nomenclature 'Accounting').

If, on the other hand, we want to use the logical operator 'or', we just need to combine the desired conditions using the '||' symbol (double vertical bars) within a single argument. Let's resume the previous example by modifying only the logical operator used:

Filter (EmployeeTable, (AnnualSalary > 10000) || (Department = “Accounting”))

This formula will now return all employees with an annual salary greater than 10,000 or those who belong to the accounting department.

Filter Power Apps: Use Cases and Practical Examples

Now that we have a better idea of how to use the Filter function in our apps, let's take a look at what are the most common use cases for this particular function within a business app.

Filter records in a gallery

When working with galleries in Power Apps, it is often necessary to give users the ability to view a subset of records. Filtering records in a gallery is a common use case where you can apply the filter function:

Filter (DataSource, SearchCriteria)

Here, DataSource refers to the data source used, and SearchCriteria specifies the conditions that records must meet to be displayed in the gallery.

For example, if you want to view only records with an 'Active' status in a gallery, you could use this formula:

Filter (Projects, Status = “Active”)

Filter records in a drop-down menu

In the same way, you can use the filter function to display specific records in the drop-down menus. If you have a drop-down menu with a list of employees and you want to show only employees with the title of accountant (here indicated with the nomenclature 'Accountant'), the syntax of our formula would be:

Filter (EmployeeList, Title = “Accountant”)

Filter based on user input

Filtering records based on user input is a very important search method to implement to provide personalized information to your users. When users enter their criteria in a text box, you can use the Filter function to view relevant records:

Filter (DataSource, SearchCriteria = UserInput.text)

For example, let's say we have a search box that allows users to search for specific projects based on a particular keyword, the formula would look like this:

Filter (Projects, TextSearchBox1.text in Title)

This line will make sure that users see only the records containing the keyword entered by the user that appears in the project title.

Are you looking for Power Apps experts?

Dev4Side Software specializes in creating business apps with Power Apps, drastically reducing internal application development and maintenance processes.

Operating vertically across the entire Microsoft Power Platform ecosystem, we have developed extensive expertise in Power Apps, which allows us to offer custom-designed and fully integrated solutions within your Microsoft 365 tenant.

Contact us to transform business information into concrete actions.

Filter Power Apps: the most common mistakes to avoid

When using the filtering function in Power Apps, you may run into some fairly common errors. These errors can often be avoided by following the best testing and quality control practices and understanding the most common problems you may encounter when developing your apps. Let's take a couple of examples.

Delegation errors

Delegation errors occur when the Filter function is combined with another function, such as an 'if' statement or the incorrect use of other logical operators within our formula.

To resolve delegation errors, we'll have to move the internal function outside of the Filter function, allowing the filter to apply the desired criteria without interference caused by other functions.

Incorrect data table references

Let's always make sure that we use the correct reference to the table when we want to apply the filter function to accurately select the data we want to search for.

We do rigorous testing and check the table names at least a couple of times, making sure that the table we're working with meets all the criteria specified by the filter formula.

Tips for using Power Apps' Filter

In order to improve the performance of your Power Apps while using the Filter function, you should consider some precautions during the development phase. Here are a few examples of what you could do.

Optimize client-side operations

When using the filter function, we consider the impact on client-side resources. Operations such as Group By, Filter By, and Merge can increase the size of the client-side JavaScript heap, causing a significant reduction in performance.

We try to change the structure of our app accordingly to minimize the impact of these operations on the resources available to the client device.

Refining formulas and the use of logical operators

Use precise formulas when defining the parts of your Filter function. The more specific you are in your selection of criteria, the easier it will be for Power Apps to process records and view accurate results.

We use logical operators in combination with the Filter function to try to provide our users with an easy way to navigate through large amounts of data.

The conscious and sensible use of the logical operators at our disposal allows the application of multiple conditions, ensuring that the records viewed by users meet the desired search criteria.

Filter Power Apps in a customer management app

To understand how the filter function works, let's now look at a small practical example and implement it in the prototype of our hypothetical customer management app.

Add a drop-down menu and items of interest

One of the best ways to use the filter function is to set conditions where you can have different matches through the data source. To do this, we must create a drop-down menu that allows us to do it.

For this example, we allow app users to filter records based on our customer's subscription type. The levels we have are Standard, Silver, Gold and Platinum.

Let's then add a drop-down menu by clicking on Input in the Insert tab.

A screenshot of a computerDescription automatically generated

If the default waterfall menu seems to be too big for the space we have, let's not worry: elements like this can be easily resized by clicking on the dots in the corners and we can also change their colors to match the theme we're using.

Now, each drop-down menu has a list of items in it. To modify the items in the drop-down menu, all we have to do is select the Elements property and type all the items inside the square brackets. Once we press Enter, we will be able to see the items inserted in the drop-down list.

So let's add the elements that we want to appear in our app. In addition to the Standard, Silver, Gold and Platinum levels, we also want an option to choose all the elements. So let's start with 'Everyone' and enter the different subscription plans later.

A screenshot of a computerDescription automatically generated

Once we press Enter, the items we have added will appear in the drop-down menu.

A screenshot of a computerDescription automatically generated

Insert the Filter function

If we choose an item in our drop-down menu, we can observe that nothing is happening at the moment. This is because we haven't yet applied the filter function to our app.

So, if we choose Standard from the drop-down menu, we want the items in our gallery to show only the items that belong to the Standard level. This means that we need to change this formula so that it performs this action.

The interesting thing about Microsoft Power Apps is that it allows you to superimpose functions on functions. This means that we don't have to delete the search formula that already exists. Instead, we can incorporate our filter function within the formula itself.

Our search function already goes through Table1 while searching for the search term entered in the search field. This is represented by TextInput1.text. Then, search for that search term in the FirstName, LastName, and AgentName columns.

Let's add Filter to the beginning of the formula, so we'll use the search formula as the first argument.

A screenshot of a computerDescription automatically generated

The first topic that filter normally looks for is a source or table, which makes sense in this case because it will filter the same table that we're using for our search filter after we finish searching for the specific search term.

Once we have the source, it's time to add the conditional logic or formula. As a condition, we want the subscription level that matches the one selected from the drop-down menu. If we check the items in the left pane, we see that we're using Dropdown2.

A screenshot of a computerDescription automatically generated

So we'll use SubscriptionLevel = Dropdown2.Selected.Value. Basically, this formula looks at the search output and filters it based on the value selected in the previously created drop-down menu of subscription types.

A screenshot of a computerDescription automatically generated

So, if we now choose Silver in the drop-down menu, for example, the entire gallery will be filtered and will only show us the entries that match our filtering criteria.

Add the 'Everyone' option to our Filter function

At this point, even though our drop-down menu now works, if we choose the 'All' option, it will still not return any results. This is because, based on the logic we created, the function is looking only for the subscription levels that we have entered.

To solve this problem, we'll add an IF statement that indicates that if the user selects' Everyone 'from the drop-down menu, then there's no need to apply this logic. If the user selects something other than 'Everyone', then this logic will still apply.

So our statement will be If (Dropdown2.Selected.Value — “Everyone”, true). This means that we want the conditional logic to return true if 'Everyone' is selected. Then, we'll add SubscriptionLevel = Dropdown2.Selected.Value so that it goes through the normal filtering process if something other than 'Everyone' is selected.

A screenshot of a computerDescription automatically generated

If we try and choose 'Everyone' in our drop-down menu, you'll see that it shows all the items in our gallery.

A screenshot of a computerDescription automatically generated

But if we choose Standard from the drop-down menu, it automatically filters the entire gallery and now shows only the entries under the Standard definition.

A screenshot of a computerDescription automatically generated

Now, let's check if both the search and filter functions work at the same time.

With Silver selected from the drop-down menu, we type the name of one of our customers in the search bar. As you can see, it doesn't return any results. This is because we are not sure that our customer is in the Silver level.

A screenshot of a computerDescription automatically generated

Then let's try the same search term using the 'Everyone' option. Now the app is showing our customer, which means that both the filter and search functions work perfectly.

A screenshot of a computerDescription automatically generated

Conclusion

In summary, using the Filter function in Microsoft Power Apps allows us to refine and restrict the data presented to users within their applications in a simple and fast way, improving the user experience and the efficiency of our apps in a significant way.

By applying specific formulas and criteria, we can always show only the information or records necessary and relevant to the needs of our users, solving the frustrating common problem of navigating through large volumes of data to find what you want.

FAQ on Filter Power Apps

How can I implement filtering in Power Apps?

To implement filtering in Power Apps, you can use the Filter function, which allows you to create a custom data set based on specific criteria. This function can filter data from various data sources, including SharePoint lists, Excel files, and SQL databases, by applying conditions to return only the relevant records.

What is the basic syntax for the Filter function in Power Apps?

The basic syntax for the Filter function in Power Apps is Filter(Source, Condition). Here, "Source" refers to the data source you want to filter, and "Condition" is the criteria you apply to filter the data. For example, Filter(Employees, Department = "HR") would return only the records where the Department field is "HR".

Can I filter multiple conditions in Power Apps?

Yes, you can filter with multiple conditions in Power Apps by using logical operators such as And, Or, and Not. For example, to filter employees who are in the HR department and have a salary greater than $50,000, you can use Filter(Employees, Department = "HR" And Salary > 50000).

How can I filter Power Apps data from a SharePoint list?

To filter Power Apps data from a SharePoint list, use the Filter function and specify the SharePoint list as the data source. For instance, Filter(SharePointListName, FieldName = "Value") will return the records from the specified SharePoint list where the field matches the given value.

Is it possible to filter a Power Apps gallery dynamically?

Yes, it is possible to filter a Power Apps gallery dynamically by using input controls like dropdowns, text inputs, or sliders. You can tie the input control's value to the Filter function's condition, allowing users to dynamically change the criteria for filtering the data displayed in the gallery.

How do I troubleshoot issues with filtering in Power Apps?

To troubleshoot issues with filtering in Power Apps, check the data source connections, ensure the correct field names and data types are used, and verify that the conditions are properly set. Also, make sure that delegation is supported by the data source for the filter operations you are performing.

What is delegation in the context of filtering in Power Apps?

Delegation refers to the process where Power Apps offloads data processing tasks to the data source rather than retrieving all records and processing them locally. This is crucial when filtering large datasets, as it ensures that only the relevant records are fetched, improving performance. However, not all data sources or functions support delegation.

Can I filter Power Apps data without delegation?

Yes, you can filter Power Apps data without delegation, but this approach is only suitable for smaller datasets due to potential performance issues. When delegation is not supported, Power Apps retrieves all records locally and applies the filter, which may lead to slow performance and app limitations with large data sets.

How does the Search function differ from the Filter function in Power Apps?

The Search function in Power Apps is used for searching text within a specific column, whereas the Filter function applies specific conditions to the entire dataset. The Search function is typically used for keyword searches, while Filter is for more complex condition-based filtering.

Can I combine Filter and Sort functions in Power Apps?

Yes, you can combine the Filter and Sort functions in Power Apps. After filtering the data set, you can use the Sort function to order the results. For example, Sort(Filter(Employees, Department = "HR"), Name, Ascending) will filter employees in the HR department and then sort them by their name in ascending order.

Get in touch with the team

Modern Apps

The Modern Apps team specializes in development and integration across the entire Microsoft 365 ecosystem. We design native applications for Microsoft and Azure platforms, and implement business processes that integrate with and maximize the investment in Microsoft 365.