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 / Replace Startswith wit...
Power Apps
Unanswered

Replace Startswith with Contains or Substring?

(0) ShareShare
ReportReport
Posted on by 387

Hi all,

Is there a way that I can replace my Startswith function with 'Contains' or 'Substring' in PowerApps?
Report Owner Name: Joe Smith

Report Number: R2021/07

So that when I search in 'Smith' or '2021' or '07' the Gallery can return the desired results.

Thank you.

 

If(

!IsBlank(
LookUp(
'Report List',
Title = varUserName
).Title),
Sort(Filter('Report List', varUserName = 'Report Owner Name' || 'Report Status'.Value = "Complete"),
StartsWith('Report Owner Name', InpSearch.Text)|| StartsWith('Report Number', InpSearch.Text)
),
else statement

)

Categories:
I have the same question (0)
  • Australia Profile Picture
    387 on at

    Or can I just use 'Search' function?

  • WarrenBelz Profile Picture
    153,026 Most Valuable Professional on at

    Hi @Australia ,

    Firstly the top filter needs to return less than 2,000 records (and your delegation setting at this) for this to work as the in filter is not Delegable

    If(
     !IsBlank(
     LookUp(
     'Report List',
     Title = varUserName
     ).Title
     ),
     With(
     {
     wList:
     Filter(
     'Report List', 
     'Report Owner Name' = varUserName || 'Report Status'.Value = "Complete"
     )
     },		 
     Sort(
     Filter(
     wList, 
     InpSearch.Text in 'Report Owner Name' ||
     InpSearch.Text in 'Report Number'
     )
     ),
     YourSortFieldHere
     ),
     else statement
    )

     

    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.

  • Australia Profile Picture
    387 on at

    Fantastic, thanks @WarrenBelz.  Could you tell me what the 'With' function does in this incidence? 

  • Australia Profile Picture
    387 on at

    And correct, my list only has about 500 rows of data (less than 2000).

    What is the advantage of using 'With' over 'Search' function highlighted in blue below? 

    If(

    !IsBlank(
    LookUp(
    'Report List',
    Title = varUserName
    ).Title),

    ),
    Sort(
    Search('Report List', InpSearch.Text,"Report Owner Name", "Report Number", "Report Date")
    ,
    'Report Date',
    Descending
    ), else statement

  • WarrenBelz Profile Picture
    153,026 Most Valuable Professional on at

    Hi @Australia ,

    I have explained it in this section of one of my blogs, but it creates a (very) temporary table which must be under 2,000 items (With() is a "hidden" Delegation limitation) which you can then filter in the rest of the statement without any Delegation issues as it is no longer querying the data source directly.

     

    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.

  • Australia Profile Picture
    387 on at

    Thanks @WarrenBelz   A little bit advanced for me to comprehend. 🤔

    So I just applied your formula and it has no red lines. But the gallery did not return any results though. Not sure what happened here?

     

    Australia_0-1632206674977.png

     

  • WarrenBelz Profile Picture
    153,026 Most Valuable Professional on at

    Hi @Australia ,

    Can you please post the exact code (in Text) you have used and also how many items are in the list. I assume you have records in your list where the Title field is your user name?

  • Australia Profile Picture
    387 on at

    Thanks @WarrenBelz.  

    Here's the full syntax:

     

    If(
    !IsBlank(
    LookUp(
    'Report List',
    Title = varUserName
    ).Title
    ),
    With(
    {
    wList:
    Filter(
    'Report List',
    'Report Owner Name' = varUserName || 'Report Status'.Value = "Complete"
    )
    },
    Sort(
    Filter(
    wList,
    InpSearch.Text in 'Report Owner Name' ||
    InpSearch.Text in 'Report Number'
    )
    ),
    'Report Date',
    Descending
    ),
    Sort(Filter('Report List', varUserName = 'Report Owner Name' || 'Report Status'.Value = "Pending"),
    StartsWith('Report Owner Name', InpSearch.Text)|| StartsWith('Report Number', InpSearch.Text)
    )

    );

     

     

     

  • WarrenBelz Profile Picture
    153,026 Most Valuable Professional on at

    Hi @Australia ,

    I assume you had something in the Search box? Anyway try this

    With(
     {
     wList:
     Filter(
     'Report List',
     Report Owner Name' = varUserName || 
     (Title = varUserName && 'Report Status'.Value = "Complete") ||
     'Report Status'.Value = "Pending"
     )
     },
     Sort(
     Filter(
     wList,
     IsBlank(InpSearch.Text) ||
     (
     InpSearch.Text in 'Report Owner Name' ||
     InpSearch.Text in 'Report Number'
     )
     ),
     'Report Date',
     Descending
     )
    )

     

    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.

  • Australia Profile Picture
    387 on at

    Fantastic, thanks very much @WarrenBelz !

    By the way can I have two 'With' functions in the syntax?

     

    For the else statement at the last of the syntax, can I use another With

    where I want to filter the list  varUserName = 'Report Auditor Name'  

     

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 796 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 327 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard