
Announcements
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))
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
)
)