web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / PowerApp not searching...
Power Apps
Answered

PowerApp not searching lastname typeahead with StartsWith/EndsWith

(0) ShareShare
ReportReport
Posted on by 184

Hi,

I have a filter function where there is a searchbox "Name_Search" and I have applied the following code with StatsWith and EndsWith function. It is working fine for the first part of the name field "Name" but it doesn't show/filter the last part of the name until I completely type the last name in the "Name" field. Such as, if anyone's name is "Leonard Baidya" in the Name field and I type Leo, it filters all the names starting with Leo. But If I type Bai, it doesn't filter the last name until I type Baidya completely. 

Is there any workaround? Or If  I can search with any keywords from any part of a name (First/Middle/Last) that would be even better. 

 

StartsWith(Name, Name_search.Text) || EndsWith(Name, Name_search.Text) &&

 

 

Here is my complete code as I have 2 drop downs and another text search box that the filter works on. 

 

Filter(
 PhoneBook,
 Category.Value = "Staff" &&
StartsWith(Name, Name_search.Text) || EndsWith(Name, Name_search.Text) &&
 (IsBlank(Callsign_search.Text) || StartsWith('Call-Sign', Callsign_search.Text)) &&
 If(
 Drop_location.Selected.Result = "All Locations",
 true,
 Location.Value = Drop_location.Selected.Result
 ) &&
 If(
 Drop_sec.Selected.Result1 = "All Sections",
 true,
 'Staff-Section'.Value = Drop_sec.Selected.Result1
 )
)

 

 

 

Appreciate your help on this.

Regards

Leo

 

Categories:
I have the same question (0)
  • Verified answer
    WarrenBelz Profile Picture
    153,084 Most Valuable Professional on at

    Hi @LeonardLeo ,

    It is doing exactly what the function is designed to do - EndsWith requires you to match the last xxx characters - so if you typed in abcd, the target field content would need to end with abcdLeonard Baidya does not end with Bai - it ends with dya.

    You could do this, which will work providing the top filter returns record numbers under your Delegation limit

    With(
     {
     _Data:
     Filter(
     PhoneBook,
     Category.Value = "Staff" &&
     (
     Len(Callsign_search.Text) = 0 || 
     StartsWith(
     'Call-Sign', 
     Callsign_search.Text
     )
     ) &&
     (
     Drop_location.Selected.Result = "All Locations" ||
     Location.Value = Drop_location.Selected.Result
     ) &&
     (
     Drop_sec.Selected.Result1 = "All Sections" ||
     'Staff-Section'.Value = Drop_sec.Selected.Result1
     )
     )
     },
     Search(
     _Data,
     Name_search.Text,
     "Name"
     )
    )

     

    Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

    MVP (Business Applications)   Visit my blog Practical Power Apps

  • LeonardLeo Profile Picture
    184 on at

    Hi Warren, 

    This is excellent! Only there was a comma missing and I have fixed it. Thanks a lot.

     

     

    Search(
     _Data,
     Name_search.Text,
     "Name"
     )

     

     

    In addition to that.. 

    I have applied your code in my 2nd screen to filter and I would like to add another Text box so that I can search with Vehicle number. Such as.. This is giving error no matter how I order the last Search code.

     

     

    With(
     {
     _Data:
     Filter(
     PhoneBook,
     Category.Value = "Services" &&
     (
     Len(Vehicle_search.Text) = 0 ||
     StartsWith(
     'Vehicle-Number', 
     Vehicle_search.Text
     )
     ) && 
     (
     Drop_location_1.Selected.Result = "All Locations" ||
     Location.Value = Drop_location_1.Selected.Result
     ) 
     )
     },
     Search(
     _Data,
     Name_search_1.Text,
     "Name"
     ) &&
    Search(
     _Data, Vehicle_Number.Text,
     "VehicleNumber"
     )
    )

     

     

  • LeonardLeo Profile Picture
    184 on at

    .

  • Verified answer
    WarrenBelz Profile Picture
    153,084 Most Valuable Professional on at

    @LeonardLeo ,

    Dangers of free-typing text - fixed on original post.

    You would be better doing this for the additional filter

    With(
     {
     _Data:
     Filter(
     PhoneBook,
     Category.Value = "Services" &&
     (
     Len(Vehicle_search.Text) = 0 ||
     StartsWith(
     'Vehicle-Number', 
     Vehicle_search.Text
     )
     ) && 
     (
     Drop_location_1.Selected.Result = "All Locations" ||
     Location.Value = Drop_location_1.Selected.Result
     ) 
     )
     },
     Filter(
     _Data,
     Name_search_1.Text in Name ||
     Vehicle_Number.Text in VehicleNumber
     )
    )

     

    Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

    MVP (Business Applications)   Visit my blog Practical Power Apps

     

  • LeonardLeo Profile Picture
    184 on at

    Dear Warren,

    Thanks a lot. It helps

    😎

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 739 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 343 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard