Get distinct values from a column and add them to a dropdown.

Get distinct values from a column and add them to a dropdown.

When any SharePoint list column is assigned to a Drop down it shows all item in it, unique and duplicates. this is really annoying in situations where we use the dropdown to filter a gallery.

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

Scenario

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

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

Let's create a simple PowerApps with gallery and a drop down to filter the gallery.

the whole SharePoint table is added as the source to gallery and the Month column 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 shown every item on the assigned column, but Ideally w 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 do 2 changes to dropdown and the gallery.

Here 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 below change.

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

then the gallery will look like this.

Conclusion

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

checkout this post on Power Automate today's date.