De-duplicate your collections in PowerApps

When you have a large array of data and and the data has duplicates, it can be difficult to to de-duplicate your data in PowerApps. There is a Distinct function which returns a unique list of values however that only works on a single field. So that is great for filling drop downs but not very good when you want to fill a gallery with data.

In this post I will describe an easy way to solve this problem.

 

I started by creating  a collection that looks like this:

[{Title:"Item1", Description: "Description 1"},
{Title:"Item1", Description: "Description 1"},
{Title:"Item2", Description: "Description 2"},
{Title:"Item3", Description: "Description 3"},
{Title:"Item3", Description: "Description 3"}
]

Within a Gallery this could look like this:

As you can see I’ve got 5 items and 2 of them are duplicates

To get my gallery to display the items I’m setting the OnStart of my app to:

ClearCollect(MyItems, {Title:"Item1", Description: "Description 1"},{Title:"Item1", Description: "Description 1"},{Title:"Item2", Description: "Description 2"},
{Title:"Item3", Description: "Description 3"},
{Title:"Item3", Description: "Description 3"}
);

Now I can use the distinct function to create myself an index unique items

ClearCollect(MyIndex, Distinct(MyItems, Title));

Using the MyIndex I can now create a gallery of list items

However this still doesn’t give me all the columns.

Now setting the label value to:

First(Filter(MyItems,Title = ThisItem.Result)).Description

Get Distinct List of items

 

Other related articles

Unique items with Distinct function

 

Advertisements

Please leave a comment or feedback

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

WordPress.com Logo

You are commenting using your WordPress.com 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.