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 Apps
Answered

Filter Search

(0) ShareShare
ReportReport
Posted on by 580

Hi All, 

 

My search function on my app is working, but will only search based on the first part of a name, for example, Joe Bloggs - The app will only search when Joe is entered and not Bloggs - So I want to be able to search the full name.

 

I also want to be able to search other fields, such as Payroll Number. 

 

I thought I had found the solution by adding & but that didn't give me red lines, but didn't work either!

 

Code I am using is:

 

 

With(
 {WMST: 'NC MST Tracker'},
 Filter(
 WMST,
 StartsWith(
 'Employee Name' & 'Payroll Number',
 TextSearchBox1.Text
 ) && Switch(
 Gallery1.Selected.Value,
 "Mentor",
 Mentor,
 "AET",
 'AET Instructor',
 "MST",
 'MST Assessor',
 true
 )
 )
)

 

 You'll see the 'Employee Name' & 'Payroll Number', - that is not actually working and I need to take 'Payroll Number' out. 

 

Any help appreciated!

 

Thanks !

Categories:
  • Drrickryp Profile Picture
    Super User 2024 Season 1 on at

    @AdamH 

    Three questions: can you separate first from last names, how many names are in your list and how many max do you expect?

  • AdamH Profile Picture
    580 on at

    @Drrickryp 

    • The name field is one field I'm afraid.
    • The current number of records is around 200
    • We have a limit of 2000 but will never reach that

    With the name field being just one SP List field - I guess that is going to make things difficult?

     

     

     

  • Drrickryp Profile Picture
    Super User 2024 Season 1 on at

    Hi @AdamH 

    No problem.  In the OnVisible property of the screen put 

     

    ClearCollect(WMST, 'NC MST Tracker')

     

     

    In your Items property

     

     

    Filter(
     WMST,
     OR(IsBlank(TextSearchBox1.Text), 
     TextSearchBox1.Text in 'Employee Name', 
     StartsWith('Payroll Number', TextSearchBox.Text
     ) && 
     Switch(
     Gallery1.Selected.Value,
     "Mentor", Mentor,
     "AET", 'AET Instructor',
     "MST", 'MST Assessor', true
     )
     )

     

     

    I have no idea about the && Switch() element but if it worked for you before, it should work here. The only concern I had was if the list was >2k, then the ClearCollect() would only get the first 2k.  Since you will never exceed this limit, the two changes should work fine. The filter will find last and first names in your name column as well as finding the start of the payroll number.

  • AdamH Profile Picture
    580 on at

    @Drrickryp 

    This does work with regards to allowing to search either first or last name / payroll but then the 'Gallery1' element which is a filter gallery made to look like buttons, stops working. 

     

    2021-04-10 17_33_38-Window.png

  • Drrickryp Profile Picture
    Super User 2024 Season 1 on at

    @AdamH 

    This is how I did a search based on 28,000 US colleges.  The entire list is filtered down by State and City then the filtered list can be searched based on the Institution and street address. 

    _1.jpg

  • AdamH Profile Picture
    580 on at

    @Drrickryp 

     

    Sorry it's been a while since I got back to you - I had to move onto another app quickly for development. 

     

    So I have changed the code a little since my original post and inserted your changes, still not liking it

     

    The code I am using now without your additions is

    With(
     {WMST: 'NC MST Tracker'}, Sort(
     Filter(
     WMST,
     StartsWith(
     'Employee Name',
     TextSearchBox1.Text
     ) && Switch(
     Gallery1.Selected.Value,
     "Mentor",
     Mentor,
     "AET",
     'AET Instructor',
     "MST",
     'MST Assessor',
     true
     )
     ),'Employee Name',If(SortDescending1, Descending,Ascending))
    )

     

    This is what I get using your code - I'm sure it's probably something I am doing wrong

    2021-04-28 14_32_41-Window.png

     

     

     

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

    @AdamH 

    There is a missing ")" for the Or statement.  I believe it should be between the ")" and the "&&" on line 10_1.png

  • AdamH Profile Picture
    580 on at

    @Drrickryp 

    You were right, there was a missing ')' - should have been )) & Switch(

     

    Thanks for you help!

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 243 Super User 2026 Season 2

#2
WarrenBelz Profile Picture

WarrenBelz 204 Most Valuable Professional

#3
Mohsin Ali Profile Picture

Mohsin Ali 122

Last 30 days Overall leaderboard