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 II
Super User II

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 User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

Power Apps Community Call

Monthly Power Apps Community Call

Did you miss the call?? Check out the Power Apps Community Call here!

secondImage

Experience what’s next for Power Apps

See the latest Power Apps innovations, updates, and demos from the Microsoft Business Applications Launch Event.

Power Platform ISV STudio

Power Platform ISV Studio

ISV Studio is the go-to Power Platform destination for ISV’s to monitor & manage applications post-AppSource publish.

Top Solution Authors
Top Kudoed Authors
Users online (35,112)