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

8 top reasons to use Dataverse or SharePoint lists in the Power Platform

Why would you use Dataverse, if SharePoint lists gives you the option to avoid premium…

3 days ago

Filter by calculated fields in SharePoint using Power Automate

When you read items from a SharePoint list and you want to filter by calculated…

4 days ago

Expected String but got Null, when calling a flow from a Model Driven app

A few weeks ago I looked at calling flows from model driven apps. And for…

6 days ago

Get all your broken connections using Power Automate

To get all your broken connections in the Power Platform can be a challenge. In…

1 week ago

Customer Voice a.k.a. Forms Pro the database behind the magic

If you call Customer Voice still Forms Pro or not, have you ever looked into…

2 weeks ago

Many running flows in Power Automate

Recently I noticed that some of my flows end up with many running flows. Types…

2 weeks ago
%%footer%%