Get distinct values from a column and add them to a dropdown on PowerApps

Ideally, the drop-down is supposed to show only unique items of assigned columns and filter according to the selected item.

But, when a non-unique column is assigned to a dropdown on Powerapps, it doesn’t automatically show only distinct values. In this post let’s find out how to do that.

Scenario

for example, let’s say we have a simple SharePoint list with month names and student names.

Student names are in a vertical gallery, and you need to add a dropdown to select the month name and filter the gallery with the selection.

We need to filter the Student name by month dropdown on Powerapps.

How to filter a gallery by a dropdown selection

Let’s create a simple PowerApp with a gallery and a drop-down to filter the gallery.

the whole SharePoint table is added as the source to the gallery and the Month column is added to the drop-down list.

To make it filter the gallery we need to make some changes.

on Gallery >> Items Filed, add this.

 
Filter( Students, Month = Dropdown1.Selected.Month )

the filter function works well but there is a problem with the dropdown.

the dropdown shows every item on the assigned column, but Ideally, we want only unique values from the column. let’s fix it.

How to get the dropdown to show only distinct values from the SharePoint column?

to do that we need to make 2 changes to the drop-down and the gallery.

Here is what should go on the dropdown >> Items.

 
Distinct(  Students , Month)

this will show only distinct months from the student table.

and on the Gallery >> Items we need to make the below change.

 
Filter(Students, Month = Dropdown1.Selected.Value   )

then the gallery will look like this.

Conclusion

PowerApps and SharePoint List is a really interesting combination if you are a PowerApps developer.

Check out this post on Power Automate today’s date.