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 / StartsWith/ Contains
Power Apps
Answered

StartsWith/ Contains

(0) ShareShare
ReportReport
Posted on by 138

Hi 

 

I have a gallery connected to a SP list with various checkboxes to filter the list. There is also a Textbox so the user can search by Username (EID.) At the moment this only works by searching the first name, but not with the surname. Therefor I think I need to change the code to search for "Contains" rather than "StartsWith" but i cant figure out how to get this to work. 

 

Here's my current code: 

 

SortByColumns(
Filter(
[@'NCL Build Schedule'],
StartsWith(EID.Email, TextSearchBox1.Text) &&
(
(Checkbox1.Value && Status.Value = "Complete") ||
(Checkbox1_1.Value && Status.Value = "Requested") ||
(Checkbox1_2.Value && Status.Value = "In Progress") ||
(Checkbox1_3.Value && Status.Value = "On Hold") ||
(Checkbox1_4.Value && Status.Value = "Ready To Ship") ||
(Checkbox1_5.Value && Status.Value = "Ready To Collect")
) && Office.Value = ComboBox1.Selected.Value
),
"DateRequiredFor",
If(SortDescending1, SortOrder.Descending, SortOrder.Ascending)
)

 

 

Please can someone help?

 

Thanks, 

 

Categories:
  • Rajkumar_M Profile Picture
    3,747 Moderator on at

    Hi

    Try this

    SortByColumns(
    Filter(
    [@'NCL Build Schedule'],
    (Contains(EID.Email, TextSearchBox1.Text) || Contains(EID.LastName, TextSearchBox1.Text)) &&
    (
    (Checkbox1.Value && Status.Value = "Complete") ||
    (Checkbox1_1.Value && Status.Value = "Requested") ||
    (Checkbox1_2.Value && Status.Value = "In Progress") ||
    (Checkbox1_3.Value && Status.Value = "On Hold") ||
    (Checkbox1_4.Value && Status.Value = "Ready To Ship") ||
    (Checkbox1_5.Value && Status.Value = "Ready To Collect")
    ) &&
    Office.Value = ComboBox1.Selected.Value
    ),
    "DateRequiredFor",
    If(SortDescending1, SortOrder.Descending, SortOrder.Ascending)
    )

    Or


    SortByColumns( Filter
    ( [@'NCL Build Schedule'],
    (EID.Email in TextSearchBox1.Text || Last(EID.Email in TextSearchBox1.Text)) &&
    ( (Checkbox1.Value && Status.Value = "Complete") || (Checkbox1_1.Value && Status.Value = "Requested") || (Checkbox1_2.Value && Status.Value = "In Progress") || (Checkbox1_3.Value && Status.Value = "On Hold") || (Checkbox1_4.Value && Status.Value = "Ready To Ship") || (Checkbox1_5.Value && Status.Value = "Ready To Collect") ) &&
    Office.Value = ComboBox1.Selected.Value ), "DateRequiredFor",
    If(SortDescending1, SortOrder.Descending, SortOrder.Ascending) )

    Thanks!

    If my response has been helpful in resolving your issue, I kindly request that you consider clicking "Accept as solution" and "giving it a thumbs up" as a token of appreciation.

  • stephenjcarr Profile Picture
    138 on at

    @Rajkumar_404  Thanks for your help. 

     

    I'm afraid neither of these work. 

     

    The first code gives an error that "Contains" is an unsupported function. 

     

    The second code gives no errors, but shows a blank gallery. 

     

    Thanks 

  • timl Profile Picture
    37,420 Super User 2026 Season 2 on at

    Hi @stephenjcarr 

    Although it's possible to do a 'contains' type search, this isn't delegable with SharePoint. Therefore, is your SharePoint list likely to contain more than 2000 rows?

  • stephenjcarr Profile Picture
    138 on at

    Hi @timl - The list is unlikely to contain over 2000 entries, as we'll be regularly removing older entries. The list currently has about 100 entries. 

    Thanks! 

  • timl Profile Picture
    37,420 Super User 2026 Season 2 on at

    Hi @stephenjcarr 

    Here's an example of the syntax that you would use to do a 'contains' search. Hopefully you can adapt that to match your exact 'Surname' column name.

    SortByColumns(
     Filter(
     [@'NCL Build Schedule'],
     (
     TextSearchBox1.Text in EID.Email ||
     TextSearchBox1.Text in Surname 
     ) ||
     (
     (Checkbox1.Value && Status.Value = "Complete") ||
     (Checkbox1_1.Value && Status.Value = "Requested") ||
     (Checkbox1_2.Value && Status.Value = "In Progress") ||
     (Checkbox1_3.Value && Status.Value = "On Hold") ||
     (Checkbox1_4.Value && Status.Value = "Ready To Ship") ||
     (Checkbox1_5.Value && Status.Value = "Ready To Collect")
     ) && Office.Value = ComboBox1.Selected.Value
     ),
     "DateRequiredFor",
     If(SortDescending1, SortOrder.Descending, SortOrder.Ascending)
    )

     

  • stephenjcarr Profile Picture
    138 on at

    Hi @timl Apologies, I should have been more clear. 

    I dont have a column for surname. I have a person field in a sharepoint list called "EID", which is then displayed in my sharepoint gallery using "EID.Email" 

     

    My search box currently only works if I search by the start of the email address, so if the address was john.smith@microsoft.com, I could search by "john" but not by "smith" so I'm looking for a way to search for any characters within the email address. 

     

    Thanks, 
    Stephen 

  • Verified answer
    timl Profile Picture
    37,420 Super User 2026 Season 2 on at

    Hi @stephenjcarr 

    Thanks for clarifying. So if you adapt the formula like so, does that work?

    SortByColumns(
     Filter(
     [@'NCL Build Schedule'],
     (
     TextSearchBox1.Text in EID.Email 
     ) ||
     (
     (Checkbox1.Value && Status.Value = "Complete") ||
     (Checkbox1_1.Value && Status.Value = "Requested") ||
     (Checkbox1_2.Value && Status.Value = "In Progress") ||
     (Checkbox1_3.Value && Status.Value = "On Hold") ||
     (Checkbox1_4.Value && Status.Value = "Ready To Ship") ||
     (Checkbox1_5.Value && Status.Value = "Ready To Collect")
     ) && Office.Value = ComboBox1.Selected.Value
     ),
     "DateRequiredFor",
     If(SortDescending1, SortOrder.Descending, SortOrder.Ascending)
    )
  • stephenjcarr Profile Picture
    138 on at

    Works great @timl 

    Thanks a lot for your 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 248 Super User 2026 Season 2

#2
WarrenBelz Profile Picture

WarrenBelz 192 Most Valuable Professional

#3
Mohsin Ali Profile Picture

Mohsin Ali 135

Last 30 days Overall leaderboard