cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
sebastianslz
Helper II
Helper II

How to avoid displaying repeated data in a gallery

have a gallery in which I am showing data from a dropdown, when selecting an item from the dropdown the gallery is loaded with the corresponding data.

 

To display the data in the gallery I make use of the Items property in which I make use of the following formula:

 

Filter(
'Warehouse';
'RecordAssigment'.Id_record = Dropdown1.Selected.Result;
StartsWith(
'Description ';
TextInput1.Text
)
)

 

What I want to avoid is that repeated data is displayed in my gallery, the following is an example of the data list, I want to avoid showing repeated data such as "Germany" or "Spain".

Description: "United Kingdom",
Description: "Germany",      
Description: "Spain",         
Description: "Germany",      
Description: "Spain",        
Description: "Germany"
I tried adding the Distinct function to the Items property of the Dropdown, but it didn't work.
 
Distinct('Warehouse';'RecordAssigment'.Id_record)
Someone knows that another function I can use to prevent the data from repeating.
1 ACCEPTED SOLUTION

Accepted Solutions
WarrenBelz
Super User
Super User

Hi @sebastianslz ,

This is "almost" Delegable as the top filter needs to return less records than your Delegation limit (it can query any number of records)

With(
   {
      wList:
      Filter(
         'Warehouse';
         'RecordAssigment'.Id_record = Dropdown1.Selected.Result &&
         StartsWith(
            'Description ';
            TextInput1.Text
         )
      )
   },
   With(
   {
      wGroups:
      AddColumns(
         GroupBy(
            wList;
            "Description ";
            "Data"
         ),
         "gID";
         First(Data).ID
      )
   },
   Filter(
      wList;
      ID in wGroups.gID
   )
)

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

Visit my blog Practical Power Apps

View solution in original post

3 REPLIES 3
WarrenBelz
Super User
Super User

Hi @sebastianslz ,

This is "almost" Delegable as the top filter needs to return less records than your Delegation limit (it can query any number of records)

With(
   {
      wList:
      Filter(
         'Warehouse';
         'RecordAssigment'.Id_record = Dropdown1.Selected.Result &&
         StartsWith(
            'Description ';
            TextInput1.Text
         )
      )
   },
   With(
   {
      wGroups:
      AddColumns(
         GroupBy(
            wList;
            "Description ";
            "Data"
         ),
         "gID";
         First(Data).ID
      )
   },
   Filter(
      wList;
      ID in wGroups.gID
   )
)

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

Visit my blog Practical Power Apps

Hi @WarrenBelz 

Thanks
for your answer, I still do not test it in my app, but could you explain a little what the With function does and why they use AddColumns and GroupBy.

@sebastianslz ,

I have a blog on the With function that may assist, but essentially it is setting a Table Variable (call it a Collection) of your filtered data - it has a limit in output governed by Delegation, but I suspect yours will be well within it. I then use GroupBy() to get the unique Description records, but this returns only one field (Description), so I also capture the ID of those records and further filter the Record Variable (at the top) by the ID, getting your entire records back for the gallery.

Helpful resources

Announcements
Power Apps News & Annoucements carousel

Power Apps News & Announcements

Keep up to date with current events and community announcements in the Power Apps community.

Community Call Conversations

Introducing the Community Calls Conversations

A great place where you can stay up to date with community calls and interact with the speakers.

Power Apps Community Blog Carousel

Power Apps Community Blog

Check out the latest Community Blog from the community!

Top Solution Authors
Top Kudoed Authors
Users online (2,663)