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 combine a Searc...
Power Apps
Answered

How to combine a SearchBox with my Sort, and Filter functions (snippet included)

(0) ShareShare
ReportReport
Posted on by 302
Sort(Filter('MySharepointList',
 //Filter by ddCompleted value
Completed.Value=ddCompleted.Selected.Value,
 //Then filter by ddName if All is not selected
ddName.Selected.Result="All"||AssignedTo.Value=ddName.Selected.Result),ID,If(SortAscending,Ascending,Descending))

This is my current Gallery code but I added a text input box called "Searchbox" and would like to incorporate it to my code.
Watching Shane Young's video my search code would be 

Search('MySharepointList', SearchBox,TicketNumber)

Just not good at combing it into my pre established statement

Categories:
I have the same question (0)
  • zmorek Profile Picture
    3,272 on at

     

    Sort(Search(Filter('MySharepointList',
     //Filter by ddCompleted value
    Completed.Value=ddCompleted.Selected.Value,
     //Then filter by ddName if All is not selected
    ddName.Selected.Result="All"||AssignedTo.Value=ddName.Selected.Result),SearchBox.Text,"TicketNumber"),ID,If(SortAscending,Ascending,Descending))

     

     

    You're close. Just wrap the Search() around the Filter() statement.

  • Verified answer
    Drrickryp Profile Picture
    Super User 2024 Season 1 on at

    @honganhuynh1 

    This will work only if "TicketNumber" is a text type column.  Search does not work with numbers.

     

    Sort(
     Search(
     Filter(
     'MySharepointList',Completed.Value=ddCompleted.Selected.Value,
     ddName.Selected.Result="All"||
     AssignedTo.Value=ddName.Selected.Result),SearchBox.Text, "TicketNumber"),
     ID,
    If(SortAscending,Ascending,Descending))

     

    Otherwise you will need to add it to your filter

     

    Sort(
     Filter('MySharepointList',
     Completed.Value=ddCompleted.Selected.Value && 
     IsBlank(SearchBox.Text)||TicketNumber=Value(SearchBox.Text) &&
     ddName.Selected.Result="All"||AssignedTo.Value=ddName.Selected.Result
     ),ID,If(SortAscending,Ascending,Descending)
    )

     

     

     

     

  • honganhuynh1 Profile Picture
    302 on at

    It is a text column and that first set of code didn't work.

    TicketNumber is a text column within my SP List 

  • honganhuynh1 Profile Picture
    302 on at

    Hey @zmorek , that didn't work unfortunately. Error was Incompatible types for comparison, These types can't be compared: Error, Text.

  • honganhuynh1 Profile Picture
    302 on at

    Hey @Drrickryp , the second option worked when I instead of Ticket number compared it to ID but then it broke my filter by Completed and by Name

  • Drrickryp Profile Picture
    Super User 2024 Season 1 on at

    @honganhuynh1

    What is your current items property? 

  • honganhuynh1 Profile Picture
    302 on at

    Completed is a Choice
    Assigned is a Choice

    ID is Number (I'm assuming)?

  • honganhuynh1 Profile Picture
    302 on at
    Sort(Filter('MySharepointList',
    //Filter by ddCompleted value
    Completed.Value=ddCompleted.Selected.Value,
    //Then filter by ddName if All is not selected
    ddName.Selected.Result="All"||AssignedTo.Value=ddName.Selected.Result),ID,If(SortAscending,Ascending,Descending))


    @Drrickryp 
    Did you mean what my current items looks like for the Gallery? If so its that

  • Drrickryp Profile Picture
    Super User 2024 Season 1 on at

    @honganhuynh1 

    This should prefilter your list by completed items and then further filter it by the AssignedTo individuals. Then sort it by ID.

     

    With({_items:Filter('MySharepointList',Completed.Value=ddCompleted.Selected.Value)},
     Sort(
     Filter(
     _items, ddName.Selected.Result="All" || 
     AssignedTo.Value = ddName.Selected.Result
     ), ID,If(SortAscending,Ascending,Descending)
    )

     

    FYI The ID metadata of a SharePoint list is unique in that it looks like a number but doesn't act like one with respect to PowerApps functions and operators.  For example, you cannot use >, <, <=, >= operators with it, only "=".  SharePoint also makes sure ID values are not reused if the record is deleted and cannot be duplicated in a list. 

  • honganhuynh1 Profile Picture
    302 on at

    Hey @Drrickryp, that returned what I had before but what about the Searchbox searching by ID 

    Searchbox's name is Searchbox
    and Id is ID 

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 638

#2
Haque Profile Picture

Haque 317

#3
WarrenBelz Profile Picture

WarrenBelz 315 Most Valuable Professional

Last 30 days Overall leaderboard