Filter
A
C
D
I
R
S
T
What is the Power Fx Filter Function?
The Filter function in Power Fx is used to filter and extract data from a data source based on a specific condition. The syntax of the Filter function is as follows:
Filter(❰Table❱, ❰Condition❱)
Here, `❰Table❱` refers to the name of the table or data source you want to filter, and `❰Condition❱` refers to the condition or criteria you want to apply to the data source.
How to Use the Power Fx Filter Function?
To use the Filter function in Power Apps, follow these simple steps:
1. Open the Power Apps Studio and create a new app or open an existing app.
2. Add a data source to your app by clicking on the ‘Data’ menu and selecting the ‘Add data source’ option.
3. Select the data source you want to use and connect it to your app.
4. Now, add a gallery or a table to your app by dragging and dropping it from the ‘Insert’ menu.
5. Select the gallery or table you just added and go to the ‘Properties’ pane on the right-hand side of the screen.
6. Scroll down to the ‘Data’ section and select the data source you want to use for the gallery or table.
7. In the ‘Fields’ section, select the fields you want to display in your gallery or table.
8. Now, go to the ‘Advanced’ tab in the ‘Properties’ pane and scroll down to the ‘Filter’ section.
9. In the ‘Filter’ section, enter the formula for the Filter function in the ‘Items’ property as follows:
Filter(❰Table❱, ❰Condition❱)
Here, `❰Table❱` refers to the name of the table or data source you want to filter, and `❰Condition❱` refers to the condition or criteria you want to apply to the data source.
10. Save and publish your app. Your gallery or table will now display only the data that meets the specified condition.
Examples of Using the Power Fx Filter Function
Here are some examples of using the Power Fx Filter function in Power Apps:
Example 1: Filtering Data Based on a Single Condition
Suppose you have a data source named ‘Customers’ with the following fields: ‘Customer Name’, ‘Country’, and ‘City’. You want to display only those customers who are from the ‘United States’. To do this, you can use the following formula:
Filter(Customers, Country = "United States")
Example 2: Filtering Data Based on Multiple Conditions
Suppose you have the same data source as in Example 1, and you want to display only those customers who are from the ‘United States’ and their city is ‘New York’. To do this, you can use the following formula:
Filter(Customers, Country = "United States" && City = "New York")
Example 3: Filtering Data Based on User Input
Suppose you have a textbox in your app where users can enter a search term to filter the data. To do this, you can use the following formula:
Filter(Customers, StartsWith(CustomerName, Textbox1.Text))
Here, ‘CustomerName’ refers to the field in the data source that contains the customer name, and ‘Textbox1.Text’ refers to the value entered by the user in the textbox.
The Filter function in Power Fx is a powerful tool for filtering and manipulating data in your Power Apps. With its flexible syntax and powerful capabilities, you can apply complex filters to your data sources and display only the data that meets your specific requirements. By following the steps outlined in this article, you can start using the Power Fx Filter function in your own Power Apps and take your app development to the next level.