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 / Gallery Filter and Sor...
Power Apps
Answered

Gallery Filter and Sort (with avoiding Delegation Issues)

(2) ShareShare
ReportReport
Posted on by 86
I have a Gallery that is connected to a Sharepoint List "HMH Administrators List"
 
The Gallery gets it's values from a Dropdown called  :
scr04_drpAccountsActiveFilter
 
In the list are 3 Columns :
 
Active (Yes/No Text Column)
HMHAdministratorsEmail (Text Colum)
HMHAdministratorsDisplayName (Text Column)
 
which are populated from an Office365User patch process.
 
I want to sort the Gallery into Ascending order of the HMHAdministratorsDisplayName value.
 
When the Screen is opened "Screen On Visible" i define a Collection : 
 
ClearCollect(collectAdministratorFilterChoices, ["All","Yes","No"]);
 
Which adds "All" to a Dropdown Box Item list (scr04_drpAccountsActiveFilter)
 
On the Gallery Item choice i added this code:
 
SortByColumns('HMH Administrators List',"HMHAdministratorsDisplayName",SortOrder.Ascending
 
which seemed to work (hopefully avoiding delegation issues too)
 
i tried adding this code too but get an error. (not sure how to use both code snippets together. As i get an error that is vague, i don't understand it and can't use it.
 
If(scr04_cmbAccountsActiveFilter.Selected.Value="All",'HMH Administrators List',Filter('HMH Administrators List',Active=scr04_drpAccountsActiveFilter.Selected.Value))
 
Basically is there a way to add these two snippets together on the Gallery Item and still avoid delegation issues. I want all Filter choices "All","Yes","No" to be filtered ascending on the HMHAdministrationDisplayName column.
 
 SortByColumns('HMH Administrators List',"HMHAdministratorsDisplayName",SortOrder.Ascending
 
and 
 
If(scr04_cmbAccountsActiveFilter.Selected.Value="All",'HMH Administrators List',Filter('HMH Administrators List',Active=scr04_drpAccountsActiveFilter.Selected.Value))
 
or an alternative more than appreciated. My skills are limited at the moment.
 
Thanks
 
 
 
 
 
I have the same question (0)
  • Suggested answer
    MS.Ragavendar Profile Picture
    7,160 Super User 2026 Season 1 on at
     
    With(
        {
            _filteredData:
                If(
                    scr04_drpAccountsActiveFilter.Selected.Value = "All",
                    'HMH Administrators List',
                    Filter(
                        'HMH Administrators List',
                        Active = scr04_drpAccountsActiveFilter.Selected.Value
                    )
                ),
            _searchedData:
                If(
                    IsBlank(txtSearch.Text),
                    _filteredData,
                    Filter(
                        _filteredData,
                        StartsWith(HMHAdministratorsDisplayName, txtSearch.Text)
                    )
                )
        },
        SortByColumns(
            _searchedData,
            "HMHAdministratorsDisplayName",
            SortOrder.Ascending
        )
    )
    I always refer the article from @WarrenBelz when the topic is about the delegation. This formula (Power Fx) has been extended to your logic based on his previous implementation and i believe this will works
     
     
    ✅If this helped, please Accept as Solution to help others ❤️ A Like is appreciated 🏷️ Tag @MS.Ragavendar for follow-ups.
  • CU10041356-0 Profile Picture
    86 on at
     
    Many thanks for the assistance and have noted the link.
     
    However it fails from :
     
     _searchedData:
                If(
                    IsBlank(txtSearch.Text),
                    _filteredData,
                    Filter(
                        _filteredData,
                        StartsWith(HMHAdministratorsDisplayName, txtSearch.Text)
                    )
                )
        },
        SortByColumns(
            _searchedData,
            "HMHAdministratorsDisplayName",
            SortOrder.Ascending
        )
    )
     
    Name isn't valid. 'txtSearch' isn't recognised.
     
    Name isn't valid '_filteredData' isn't recognised.
     
    Any ideas? Don't know how this really works, so a bit stuck.
     
  • Verified answer
    MS.Ragavendar Profile Picture
    7,160 Super User 2026 Season 1 on at
     
    I understood the requirement you have drop down to filter records and search box as well to filter the records so based on that logic the below code was provided here you need to replace txtSearch with your actual textbox name (actual control name.Text) if the text box exists.
     
    If there is no textbox control then try with the below formula and also please provide the UI for finer solutions
     
    With(
        {
            _filteredData:
                If(
                    scr04_drpAccountsActiveFilter.Selected.Value = "All",
                    'HMH Administrators List',
                    Filter(
                        'HMH Administrators List',
                        Active = scr04_drpAccountsActiveFilter.Selected.Value
                    )
                )
        },
        SortByColumns(
            _filteredData,
            "HMHAdministratorsDisplayName",
            SortOrder.Ascending
        )
    )
     
    ✅If this helped, please Accept as Solution to help others ❤️ A Like is appreciated 🏷️ Tag @MS.Ragavendar for follow-ups.
     
  • CU10041356-0 Profile Picture
    86 on at
    Sorry no.
    I am not searching on the Gallery.
    Just a Dropdown which Filters "All","Yes","No"
     
    Will try what you suggested.
     
    Thanks again.
     
     
     
  • CU10041356-0 Profile Picture
    86 on at
    That worked great - thank you so much.

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 834

#2
Valantis Profile Picture

Valantis 533

#3
Haque Profile Picture

Haque 410

Last 30 days Overall leaderboard