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 / How to nest Search, so...
Power Apps
Answered

How to nest Search, sort and Filter in items

(0) ShareShare
ReportReport
Posted on by 68

Hi all,

next, but hopefully last issue before I finish my Ticketing App 🙂

 

I want to be able to have Users filter a Gallery for either all items or items they created.

For this, I have created a new gallery with the items "All" and "My Tickets".

 

So technically all I need to do is to set the items property of the Ticket Gallery to include 

 

If(
FilterGallery.Selected.Value = "My Tickets";
Filter('Incident Meldung';'Erstellt von'.Email = varCurrentUser);

 

However, in the items property I already have the following: 

 

Search(
Sort(
'Incident Meldung';
ID;
SortOrder.Descending
);
Searchbar.Text;
"Title"
)

 

How do I nest these commands together for it to work?

 

 

Categories:
  • Verified answer
    Ami K Profile Picture
    15,689 Super User 2024 Season 1 on at

    @Puddlerunna we can nest the functions together this way:

     

    Search(
     Sort(
     Filter(
     'Incident Meldung';
     FilterGallery.Selected.Value = "All Tickets" || 'Erstellt von'.Email = varCurrentUser
     );
     ID;
     SortOrder.Descending
     );
     Searchbar.Text;
     "Title"
    )

     

    Note that the Search function is not delegable.

     

    However, if we can be certain that the Filters will return less than 2000 rows (the max delegation limit), we can "pre-filter" the List using the With function, and then apply our Search function on that smaller subset of data.

     

    With(
     {
     _prefiltered_data: Sort(
     Filter(
     'Incident Meldung';
     FilterGallery.Selected.Value = "All Tickets" || 'Erstellt von'.Email = varCurrentUser
     );
     ID;
     SortOrder.Descending
     )
     };
     Search(
     _prefiltered_data;
     Searchbar.Text;
     "Title"
     )
    )
    

     

     

  • PPDEV Profile Picture
    142 on at

    Hello @Puddlerunna , could you please attempt on this sequence?

    Sort(
     Search(
     If(
     FilterGallery.Selected.Value = "My Tickets",
     Filter(
     'Incident Meldung',
     'Erstellt von'.Email = varCurrentUser
     ),
     'Incident Meldung'
     ),
     Searchbar.Text,
     "Title"
     ),
     ID,
     SortOrder.Descending
    )

    Feel free to modify the syntax according to your needs.

    Please tag this as accepted solution if it resolves your issues. Thank you!

  • Puddlerunna Profile Picture
    68 on at

    Hi @Amik,

     

    thank you! That does the trick.

     

    It poses another challenge now though 🙂 Maybe you can help here, too?

    For the Ticket Gallery I have a variable that ensures that when e.g. cancelling adding a new record the latest Item is selected again and displayed in the form. 

     

    Gallery.Default: varGalleryDefault

    Gallery.OnSelect: ResetForm(Form1);;ViewForm(Form1);;Set(varGalleryDefault, ThisItem);;

     

    If now in my "All Tickets" View I have selected a record that's not created by my user and I switch to the "MyTickets" view, no item is selected and the form returns "No Elements to be displayed".

     

    How can I make it display my latest record?

     

  • Puddlerunna Profile Picture
    68 on at

    Thanks @ppDev_30"! It works.

    Marking Amik's answer as the solution though as he was first to respond 🙂

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 220 Super User 2026 Season 2

#2
WarrenBelz Profile Picture

WarrenBelz 189 Most Valuable Professional

#3
Mohsin Ali Profile Picture

Mohsin Ali 139

Last 30 days Overall leaderboard