Skip to main content

How to Count Unique Values in Power Apps with Distinct

· 5 min read
Jagdish Kumawat
Founder @ Dewiride

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​

Syntax
Distinct(Table, Formula)
PartWhat it is
TableThe table to look through.
FormulaWhat 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:

Count the unique values
CountRows(Distinct(Table, Formula))
List the unique values as text
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:

lblCountsRS → Text
With(
{
entries: CountRows(locRowsRS),
people: CountRows(Distinct(locRowsRS, Email))
},
$"{entries} {If(entries = 1, "entry", "entries")} from {people} {If(people = 1, "person", "people")}"
)

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:

Part of galPeopleRS → Items
Departments, Concat(Distinct(Rows, Department), Value, ", ")

The Result​

Six approved entries from four people:

The lines Approved hours in November 2026: 20.25 and 6 entries from 4 people

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

A person card with the name Admin User and the line 10.00 hours in Emergency Department, Radiology

Common Mistakes​

MistakeWhat happensDo this instead
CountRows(locRowsRS) for peopleCounts entries, not peopleCountRows(Distinct(locRowsRS, Email))
Counting names instead of emailsPeople who share a name count as oneCount a column that's unique per person
Using the column's own name after DistinctThe result's column is called ValueValue
Distinct on a large SharePoint listOnly the first part of the list is countedFilter in the data source first, or bring the rows in another way

Troubleshooting​

SymptomLikely causeFix
The count is higher than expectedThe same value is written in different ways, for example with a trailing spaceMake the values consistent when the table is built, for example with Trim()
A delegation warningDistinct on a data sourceUse a table already in the app
The text list repeats a valueThe list joins the table, not its distinct valuesConcat(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, ", ").

Additional Resources​