Microsoft PowerApps – Filter Collection using List Box Control and Distinct

Let’s continue building on the customers list from the previous post by demonstrating how we can filter the collection that drives our customers data table. Our simple filter UI will be built using a List Box control and will also demonstrate the use of the Distinct function.

Populate the List Box Control with Distinct

In this example, we’ll filter customers by City. For reference, our collection definition is:

customersCollection,{Name: "", Address1: "", Address2: "",City: "", State: "",'Zip Code': ""}

To populate the List Box by the “City” property, your first approach may be to set the “Items” property to:


The problem is that the above does not remove duplicates, and that is where the Distinct function comes in. The correct setting for the Items property is:


The only other requirement for our filter is that it’s for a single City selection only. To avoid any confusion, set the List Box Select multiple property to “Off” / false.

Reset the List Box Control

Resetting the List Box is straightforward. Add an icon or button of your choice and set its OnSelect property:


Note that “FilterBox” is the name Name of the List Box.

Filter the Data Table

The requirement is to show all customers, or show only those customers with a City that matches the FilterBox selection. To test whether or not an item is selected, I’ll use the Len function. The final filter is applied to the Items property on the data table.

If(Len(FilterBox.Selected.Result) > 0, Filter(customersCollection, City = FilterBox.Selected.Result),customersCollection)

Here’s a test to validate:

Categories: Apps, Microsoft PowerApps, Office 365 and O365

Tags: , ,

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: