web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Write Gallery Distinct...
Power Apps
Unanswered

Write Gallery Distinct Code Based on Name and Date

(0) ShareShare
ReportReport
Posted on by 5,331 Moderator

I have Gallery1 and Gallery2.

Gallery1 is displaying employee data from an SPList.

Each employe may have multiple lines of information on the SPList.

I only want the employee's name to appear once (Distinct) in Gallery1, based on the first/earliest date associated with their appearance on SPList.

I have searchable ComboBox1 that is also involved.

I need to add a distinct to the current gallery formula, how to I achieve this task?

Gallery1 formula is currently -
     If(IsBlank(ComboBox1.Selected.Value),Collection1,Filter(Collection,Title = ComboBox1.Selected.Value))


Categories:
I have the same question (0)
  • cha_cha Profile Picture
    4,932 Moderator on at

    Hello @Phineas 

     

    This would be the gallery details if you want to only get the EmployeeName and Earliest AppearanceDate.

    You will need to use AddColumns and GroupBy Functions, optionally you can add a dropdown. As for your syntax, we will need to modify it a avoid repetitions of code. This will be the structure that we will follow for the additional codes.

    Filter(
     Collection1, 
     If(
     IsBlank(ComboBox1.Selected.Value)
     ,true
     ,Title = ComboBox1.Selected.Value
     )
    ) 

     

     Updated code with EarliestAppearance which will contain the earliest appearance date. 

    Filter(
     AddColumns(
     GroupBy(
     Collection1,
     "Title", //Assuming Title contains employee name in sharepoint
     "EmployeeDates" //You can decide ever name you like here
     )
     ,"EarliestAppearanceDate" //You can decide also what name here
     ,Min(EmployeeDates,AppearanceDate)
     )
     , 
     If(
     IsBlank(ComboBox1.Selected.Value)
     ,true
     ,Title = ComboBox1.Selected.Value
     )
    ) 

     

    If you prefer a cleaner code, you can also remove columns that may not be relevant to this gallery.

    Filter(
     DropColumns(
     AddColumns(
     GroupBy(
     Collection1,
     "Title", //Assuming Title contains employee name in sharepoint
     "EmployeeDates" //You can decide ever name you like here
     )
     ,"EarliestAppearance" //You can decide also what name here
     ,Min(EmployeeDates,AppearanceDate)
     ),
     "EmployeeDates"
     )
     , 
     If(
     IsBlank(ComboBox1.Selected.Value)
     ,true
     ,Title = ComboBox1.Selected.Value
     )
    ) 

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the April Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
Vish WR Profile Picture

Vish WR 846

#2
Valantis Profile Picture

Valantis 532

#3
Haque Profile Picture

Haque 410

Last 30 days Overall leaderboard