How to Count Unique Values in Power Apps with Distinct
A table of six overtime entries can come from four people. To say from 4 people, the app needs the number of different people, not the number of rows. Distinct gives the unique values of a column, and CountRows counts them.
Syntax
Distinct(Table, Formula)
| Part | What it is |
|---|---|
| Table | The table to look through. |
| Formula | What to take from each record, usually a column's name, such as Email. |
From Microsoft's Distinct reference: it returns a one-column table of the results with duplicate values removed. The name of the column is Value. Two common uses:
CountRows(Distinct(Table, Formula))
Concat(Distinct(Table, Formula), Value, ", ")
With a data source such as a SharePoint list, Distinct isn't delegated: Power Apps works on the first part of the data only. Use it on a table already in the app, or on a data source small enough to load whole.
The examples are from the Reports screen of the Overtime Timesheet app. locRowsRS is a table of a month's approved overtime entries, one row per entry, with Employee, Email, Department and Hours columns. It comes from a flow, so it's all in the app.
Step 1: Count the Different People
The label lblCountsRS says how many entries there are and from how many people. Entries are rows; people are the different emails:
With(
{
entries: CountRows(locRowsRS),
people: CountRows(Distinct(locRowsRS, Email))
},
$"{entries} {If(entries = 1, "entry", "entries")} from {people} {If(people = 1, "person", "people")}"
)
Distinct(locRowsRS, Email)is one row per different email.CountRows(...)counts those rows.- With names both numbers, so the text uses each one twice: once as a number and once to choose entry or entries (How to Use the With Function in Power Apps and How to Join Text in Power Apps with Ampersand and String Interpolation).
The email is the column to count, not the name: two people can share a name, and one person's name could be spelt differently on two entries.
Step 2: List the Different Values
On the screen's list of people, each person's card says which departments their hours are from. The list groups the entries by email, and each group's entries are in a column called Rows (How to Group Records in Power Apps with GroupBy). The departments column of each person:
Departments, Concat(Distinct(Rows, Department), Value, ", ")
Distinct(Rows, Department)is the person's different departments, in a column named Value.Concat(..., Value, ", ")joins them with a comma and a space (How to Join Table Values into Text in Power Apps with Concat).
The Result
Six approved entries from four people:

One person had three entries in two departments, and their card names each department once:

Common Mistakes
| Mistake | What happens | Do this instead |
|---|---|---|
CountRows(locRowsRS) for people | Counts entries, not people | CountRows(Distinct(locRowsRS, Email)) |
| Counting names instead of emails | People who share a name count as one | Count a column that's unique per person |
| Using the column's own name after Distinct | The result's column is called Value | Value |
| Distinct on a large SharePoint list | Only the first part of the list is counted | Filter in the data source first, or bring the rows in another way |
Troubleshooting
| Symptom | Likely cause | Fix |
|---|---|---|
| The count is higher than expected | The same value is written in different ways, for example with a trailing space | Make the values consistent when the table is built, for example with Trim() |
| A delegation warning | Distinct on a data source | Use a table already in the app |
| The text list repeats a value | The list joins the table, not its distinct values | Concat(Distinct(...), Value, ", ") |
FAQ
Is Distinct case-sensitive?
The example doesn't depend on it: the emails are written in lower case when the table is built, with Lower(Text(ThisRecord.email)), so the same email always looks the same (How to Convert Text to Lower Case in Power Apps with Lower).
Can Distinct take a formula, not just a column?
Yes: Formula is evaluated for each record, so Distinct(locRowsRS, Year(WorkDate)) would give the different years, if the table had a WorkDate column.
How do I sort the unique values?
Sort the result by Value: Sort(Distinct(Table, Column), Value), as in Microsoft's example.
Conclusion
Distinct gives the unique values of a column as a one-column table named Value. Count them with CountRows(Distinct(...)), and list them with Concat(Distinct(...), Value, ", ").
