PowerApps – Get your unique items listed in a gallery

The basic Distinct function usage

In this post I’m looking at creating unique values within a gallery in PowerApps. I started by creating a Gallery with a list of items by feeding the gallery with some json containing some titles set to numbers.

Gallery with items

The labels control that I’m using is set to thisItem.Value.Title and this displays each number related to each item in my array of items.

Label

Now I’m going to take that same array of items but I want to only display unique items. In short on of the two “4” items should disappear.

This can be done with the Distinct functions however it will be needed to convert the array into a Table first. This can be done with the Table function.

Note that in the above there isn’t an array in my Table but a number of records passed into the Table.

Gallery with records

Also note that the labels in this gallery need to be set to ThisItem.Result for them to appear properly in the overview presented by my second gallery.

Distict labels

 

Moving towards Tables

Very soon we will see why feeding the gallery with an array of items may not be the best idea. To make the above two examples more similar I’m going to feed both Galleries with Tables. My first Gallery will now have items that look like this look like this.

Items with table

Now I can use the items in Gallery 1 as a source for Gallery 2, once again with the Distinct function, but as the Items in Gallery 1 are using a Table it is now a piece of cake to get unique values back! Note that the Distinct function only takes Tables and not arrays or collections.

Distinct table

So in short, if you have a choice of feeding a Gallery with a collection or a table, then you might want to choose a table instead. It makes it a lot easier to use function like distinct.

 


Discover more from SharePains

Subscribe to get the latest posts sent to your email.

Avatar of Pieter Veenstra

Is your business still running on paper trails, sprawling Excel files, or ageing Access databases? There's a better way — and I can show you exactly what it looks like. I'm the Technical Director of Vantage 365, a Microsoft solutions consultancy working with clients across the UK, the Netherlands, and worldwide. For over 30 years I've been turning messy, manual business processes into clean, automated systems that save time, reduce errors, and give teams the visibility they need to make better decisions. SharePains is not just any blog run by a Microsoft MVP. Have you ever used Try-Catch in Power Automate? The original post about Try-Catch in Power Automate can still be found on this site, https://sharepains.com/2018/02/07/try-catch-finally-in-power-automate-flow/ Or have you ever used the Pieter’s method to avoid variables and speed up your flows? https://sharepains.com/2020/03/11/pieters-method-for-advanced-in-flows/ You can contact me using contact@sharepains.com

Related Posts

Leave a Reply

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

Discover more from SharePains

Subscribe now to keep reading and get access to the full archive.

Continue reading