I have a Gallery that I am filtering using the following. There are some 600 items in the list, and I am filtering out 271 of them to display in the Gallery.
I am trying to get the items to show in A - Z order. Of the 271 items the first 220 appear in alphabetical order starting with 'C', by last name. The last fifty start again with the last names that start with 'A'. These 'A' names should be at the top of the Gallery.
Gallery1 items -
If(IsBlank(Name_Search_Fld.Text), Filter(DataCollection, PersonType="Teacher", Region = "North", Basis = "1",
FirstName,SortOrder.Descending),
Filter(DataCollection,FirstName=Name_Search_Fld.Text, Region = "North",Basis = "1",FirstName,SortOrder.Descending))
I messed around and accidently stumbled over my answer.
If(IsBlank(Name_Search_Fld.Text),
Sort(Filter(
DataCollection,
PositionType="Teacher",
Region = "North",
Basis = "1"),
FirstName,
SortOrder.Ascending
),
Sort(Filter(DataCollection,
StartsWith(FirstName,Name_Search_Fld.Text),
PositionType = "Teacher",
Region = "North",
Basis = "1"),SortOrder.Ascending
))
How do I squeeze in a StartsWith for the lower 'search' function, so that the Gallery populates when the first letter is typed into the search box, rather than having to wait for the entire name to be entered?
Hi @Phineas
In addition to what @LaurensM says, you're also missing the actual call to the Sort function.
If(
IsBlank(Name_Search_Fld.Text),
Sort(Filter(
DataCollection,
PersonType = "Teacher",
Region = "North",
Basis = "1")
FirstName,
SortOrder.Ascending
),
Sort(Filter(
DataCollection,
FirstName = Name_Search_Fld.Text,
Region = "North",
Basis = "1")
FirstName,
SortOrder.Ascending
)
)
Hi @Phineas,
You are currently filtering your gallery by first name descendingly (z - a). You will have to change this for both Filters to the Last Name column and SortOrder.Ascending.
If this solves your question, would you be so kind as to accept it as a solution & give it a thumbs up.
Thanks!
WarrenBelz
146,660
Most Valuable Professional
RandyHayes
76,287
Super User 2024 Season 1
Pstork1
65,999
Most Valuable Professional