cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
mrizz
Frequent Visitor

Distinct in a Gallery

I have a gallery connected to a SQL table. There are multiple columns that I want the gallery to be connected to, but 1 of those columns I want to use a distinct filter on. However when I use the distinct filter, I cannot use any of the other columns in the galley, only the resulting column from the distinct function. How can I use the distinct column and another column from the table in a gallery. 

2 REPLIES 2
Drrickryp
Super User
Super User

Hi @mrizz 

To filter your gallery on a unique set of values, put a dropdown outside of the gallery and set its items property to  

 

Sort(Distinct(yoursqltable,Column2makeUnique),Result,Ascending)

 

Make the gallery items property:

 

Filter(yoursqltable,Column2makeUnique=Dropdown1.Selected.Result)

 

Distinct() takes a single field in the datasource and creates a 1 column table of unique values from the selected field and names it "Result". 

If (for some reason) you want the have a dropdown inside of the gallery, you can put the same one there and change the Default to ThisItem.Column2makeUnique. 

Replace the "Column2makeUnique" above with the name of the field you are referring to.

v-bofeng-msft
Community Support
Community Support

Hi @mrizz :

Do you want to get the table after removing duplicate data based on a certain field.

My method is to use forall and lookup nested way to get the table:

 

ForAll(Distinct(YourDatasource,TheSpecifiedField),LookUp(YourDatasource,TheSpecifiedField=Result))

 

I've made a test for your reference:

My data source:'List A'

1.JPG

1\Add a gallery and set it's Items property to:

 

ForAll(Distinct('List A',Title),LookUp('List A',Title=Result))

 

2.JPG

Duplicate records are eliminated,at the same time all fields are reserved.

Best Regards,

Bof

Helpful resources

Announcements
PA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.

Microsoft Build 768x460.png

Microsoft Build is May 24-26. Have you registered yet?

Come together to explore latest innovations in code and application development—and gain insights from experts from around the world.

May UG Leader Call Carousel 768x460.png

What difference can a User Group make for you?

At the monthly call, connect with other leaders and find out how community makes your experience even better.

Top Solution Authors
Top Kudoed Authors
Users online (3,312)