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

Notifications

Announcements

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,325 Super User 2025 Season 2

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 765 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 343 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 272

Last 30 days Overall leaderboard