Select

How to Use the Power Fx Select  Function in Power Apps

Understanding the Select Function

The Select function in Power Fx allows you to select and transform data from a table or collection. The syntax of the Select function is as follows:


Select( TableOrCollection, Formula )


Here, TableOrCollection is the table or collection from which you want to select the data, and Formula is the formula that you want to apply to transform the data. The formula can be any valid Power Fx formula that operates on a single record from the table or collection.

Filtering Data using Select Function

You can use the Select function to filter data based on a condition. The condition can be any valid Power Fx formula that evaluates to true or false. The syntax for filtering data using the Select function is as follows:


Select( TableOrCollection, Formula, FilterFormula )


Here, FilterFormula is the formula that you want to apply to filter the data. The FilterFormula should evaluate to true or false. The Select function will only return the records for which the FilterFormula evaluates to true.

For example, let's say you have a collection named "Employees" that contains the following fields: Name, Age, Gender, and Salary. If you want to filter the employees who are over 30 years old, you can use the following formula:


Select( Employees, Name, Age ❱ 30 )


This formula will return the names of all employees who are over 30 years old.

Transforming Data using Select Function

You can also use the Select function to transform data in your app. The formula that you use to transform the data should operate on a single record from the table or collection. The syntax for transforming data using the Select function is as follows:


Select( TableOrCollection, Formula, Blank(), TransformFormula )


Here, TransformFormula is the formula that you want to apply to transform the data. The TransformFormula should operate on a single record from the table or collection and return a single value.

For example, let's say you have a collection named "Products" that contains the following fields: Name, Price, and Quantity. If you want to calculate the total price of each product, you can use the following formula:


Select( Products, Name, Blank(), Price * Quantity )


This formula will return the names of all products along with their total price.

Combining Filtering and Transformation

You can also combine filtering and transformation using the Select function. The syntax for combining filtering and transformation is as follows:


Select( TableOrCollection, Formula, FilterFormula, TransformFormula )


Here, FilterFormula is the formula that you want to apply to filter the data, and TransformFormula is the formula that you want to apply to transform the data.

For example, let's say you have a collection named "Orders" that contains the following fields: Product, Quantity, and Date. If you want to calculate the total price of orders for a specific product that were placed after a certain date, you can use the following formula:


Select( Orders, Blank(), Product = “Product Name” And Date ❱ Date(2021, 1, 1), Quantity * Price )


This formula will return the total price of all orders for the "Product Name" that were placed after January 1, 2021.

The Power Fx Select function is a powerful tool for filtering and transforming data in Power Apps. It allows you to create complex calculations and logic within your app without the need for coding. By understanding the syntax and usage of the Select function, you can create custom business applications that meet your specific needs.

Power Apps Training Courses by G Com Solutions (0800 998 9248)