Categories: Microsoft 365

Create Distinct filters for Power Apps galleries

So you add a gallery to your app in Power Apps and you want to create some filters (distinct filters of course!). This is the post to read!

Galleries

I’ve said it before, Galleries are everywhere in Power Apps.

The simplest form of using galleries is listing data that comes from lists or tables.

Below I’ve got an example of a gallery that shows data from a SharePoint list that contains information about all connectors in the Power platform.

Building distinct filters on a gallery

I now want to build a dropdown that will filter my data on the Release column. This column has the internal name of Release Tag.

First of all I’m going to add a dropdown control in my Power App. This dropdown will appear just above the header of the the column.

Then it is important that every value of the Release column in my Connectors list will only appear once in my dropdown.

The most obvious way is to set the items in my dropdown to the following code, using the distinct filters to filter the gallery. Using the distinct function you will make sure that you only get the unique values.

distinct(Connectors.'Release Tag', 'Release Tag').Result

However this doesn’t work. The dropdown will remain empty.

Note that when you set a collection to hold the result that you will get a better working filter.

So in my case I’m going to set a collection called colFilter using the follownig line of code in my app startup.

Collect(colFilter, Distinct(Connectors.'Release Tag','Release Tag').Result)

You could also do this within the screens’ OnVisible configuration or maybe in a timer if you want your dropdowns to update on a regular basis.

And now the possible options are displayed as expected.

And now as we select a value from our dropdown the right records appear in our gallery.

Share
Pieter Veenstra

Business Applications and Office Apps & Services Microsoft MVP working as a Microsoft Productivity Principal Consultant at HybrIT Services. You can contact me using contact@veenstra.me.uk.

Recent Posts

Create new group alert using Power Automate

Do you want to know when a new group has been created with for example…

3 days ago

Delegation Warnings in Power Apps

We have all seen them, Delegation Warnings, but what is delegation and how do you…

3 days ago

1 Top tip: PowerPlatformLearn.com and master the Power Platform within no time

It can be difficult to get started with the Power Platform, blogs help, training helps,…

1 week ago

Compare 2 Excel files using Power Automate

This is such a common scenario. You receive Excel files on a regular basis and…

2 weeks ago

Rename SharePoint folders using Power Automate in 2 easy steps

Have you ever wanted to rename SharePoint folders with Power Automate? REST API call to…

3 weeks ago

Read dates from Excel with Power Automate

To read dates from Excel files can be tricky, as Excel only give you the…

4 weeks ago
%%footer%%