When you have large arrays or collections of data and and the data has duplicates, you migth want to use the PowerApps distinct function
Power Apps distinct function
Table of Contents
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:
[{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

Other related articles
Unique items with Distinct function
Discover more from SharePains
Subscribe to get the latest posts sent to your email.

Genius!! Saved my life!
I’m glad this post helped you.