Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Apps - Building Power Apps
Answered

Filter Gallery by Last Name A - Z

(0) ShareShare
ReportReport
Posted on by 4,704 Super User 2025 Season 1

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

Categories:
  • Verified answer
    Phineas Profile Picture
    4,704 Super User 2025 Season 1 on at
    Re: Filter Gallery by Last Name A - Z

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

  • Phineas Profile Picture
    4,704 Super User 2025 Season 1 on at
    Re: Filter Gallery by Last Name A - Z

    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?

  • Verified answer
    timl Profile Picture
    34,941 Super User 2025 Season 1 on at
    Re: Filter Gallery by Last Name A - Z

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

     

  • LaurensM Profile Picture
    12,510 Super User 2025 Season 1 on at
    Re: Filter Gallery by Last Name A - Z

    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!

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

🌸 Community Spring Festival 2025 Challenge 🌸

WIN Power Platform Community Conference 2025 tickets!

Markus Franz – Community Spotlight

We are honored to recognize Markus Franz as our April 2025 Community…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 146,660 Most Valuable Professional

#2
RandyHayes Profile Picture

RandyHayes 76,287 Super User 2024 Season 1

#3
Pstork1 Profile Picture

Pstork1 65,999 Most Valuable Professional

Leaderboard