A
C
D
I
R
S
T
What is the Power Fx Distinct Function?
The Distinct function is used in Power Apps to remove duplicates from a table or a collection. It returns a new table or collection with unique values based on a column or columns you specify.
The syntax for the Distinct function is as follows:
Distinct( Table/Collection, Column1 [, Column2, …] )
– Table/Collection: Required. The name of the table or collection from which you want to remove duplicates.
– Column1: Required. The name of the column from which you want to remove duplicates.
– Column2: Optional. Additional columns from which you want to remove duplicates.
How to Use the Distinct Function in Power Apps
Here’s an example scenario where we can use the Distinct function. Let’s say we have a collection named “Employees” with the following data:
| Employee ID | Name | Department |
| — | — | — |
| 1 | John Smith | Sales |
| 2 | Jane Doe | Marketing |
| 3 | John Smith | Sales |
| 4 | Bob Johnson | HR |
In this case, we want to remove the duplicate entries of “John Smith” in the “Name” column. Here’s how we can use the Distinct function to achieve this:
1. Create a new label on the screen and set its Text property to the following formula:
Concat(Distinct(Employees, Name), Name & ", ")
This formula will return a comma-separated list of unique values from the “Name” column in the “Employees” collection.
2. Save and run the app. The label will display the following text:
John Smith, Jane Doe, Bob Johnson
As you can see, the duplicate entry of “John Smith” has been removed from the list.
Additional Examples
Here are some additional examples of how you can use the Distinct function in Power Apps:
– If you want to remove duplicates based on multiple columns, you can specify them as additional arguments in the Distinct function. For example:
Distinct(Employees, Name, Department)
This will return a new table/collection with unique combinations of values in the “Name” and “Department” columns.
– You can also use the Distinct function with filters to remove duplicates from a subset of data. For example:
Distinct(Filter(Employees, Department = "Sales"), Name)
This will return a new table/collection with unique values in the “Name” column for all employees in the “Sales” department.
The Power Fx Distinct function is a powerful tool for removing duplicates from your data in Power Apps. By following the examples outlined in this article, you should now have a good understanding of how to use the function in your own apps.