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 / Compare two sentences ...
Power Apps
Answered

Compare two sentences split with space

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

I have a complex requirement that I cannot figure out the correct syntax. I have a gallery control load with various UserNames.

e.g. Peter OO Parker, Michael AZ Jackson, Turd AB Ferguson.

In the TextSearchBox1 user can type in multiple keywords. e.g. "Peter Parker", "ter ker"

I want user can find "Peter OO Parker" when type in "Peter Parker". He should not find it by type in "ter ker".

 

Thank you very much.

 

Categories:
I have the same question (0)
  • v-bofeng-msft Profile Picture
    Microsoft Employee on at

    Hi @Anonymous :

    I'v made a test for your reference:

    1\My data source:

    ClearCollect(Testcollection,["Peter OO Parker","Michael AZ Jackson","Turd AB Ferguson"])

    2\The formula

    Filter(
     Testcollection,
     Sum(
     ForAll(
     Split(
     TheTextInputControl.Text,
     " "
     ),
     If(
     !(Result in Split(
     Value,
     " "
     )),
     {Count: 1},
     {Count: 0}
     )
     ),
     Count
     ) = 0
    )

    20.gif

    Best Regards,

    Bof

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    I amended some syntax to fit my original query. But it prompt me "The function Split has some invalid agrument". The warning line is under Split(Value," ")

     

    // some conditions
    ||(Sum(ForAll(Split(TextSearchBox1.Text," "),If(!(Result in Split(Value," ")),{Count: 1},{Count: 0})),Count) = 0)
    || // some conditions

     

    Is my change cause Value not being recognized?

  • v-bofeng-msft Profile Picture
    Microsoft Employee on at

    Hi @Anonymous :

    On your side the formula should be:

    Filter(
    YourDataSource,
    Sum(
    ForAll(
    Split(
    TheTextInputControl.Text,
    " "
    ),
    If(
    !(Result in Split(
    Name,
    " "
    )),
    {Count: 1},
    {Count: 0}
    )
    ),
    Count
    ) = 0
    )

     

    Best Regards,

    Bof

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Thanks v-bofeng-msft, the formula is working now. Is it possible to change the compare condition to "StartsWith"? So that input "Pet Par" can return result?

  • v-bofeng-msft Profile Picture
    Microsoft Employee on at

    Hi @Anonymous :

    Yes.

    Best Regards,

    Bof

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Because "StartsWith" do not work with a collection or table (e.g. Split(Name," ")). Should I use a nested "ForAll" for my purpose? 

     

    It is my start but full of syntax error:

     

    (Sum(ForAll((Split(TextSearchBox1.Text," ") As A),(ForAll(Split(Name," ") As B),If(!(A.Result in B.Result),{Count: 1},{Count: 0}))),Count) = 0)
  • Verified answer
    v-bofeng-msft Profile Picture
    Microsoft Employee on at

    Hi @Anonymous :

    Please try :

     

    Filter(
     Testcollection,
     Sum(
     ForAll(
     Split(
     TheTextInputControl.Text,
     " "
     ) As Table1,
     If(
     Sum(
     ForAll(
     Split(
     Name,
     " "
     ) As Table2,
     If(
     StartsWith(
     Table2[@Result],
     Table1[@Result]
     ),
     {Count: 1},
     {Count: 0}
     )
     ),
     Count
     ) = 0,
     {Thecount: 1},
     {Thecount: 0}
     )
     ),
     Thecount
     ) = 0
    )

     

    In addition, if your previous problem has been solved but you still want to ask a new one, please consider marking my reply as "solution" and creating a new thread.

    Best Regards,

    Bof

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

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 355 Most Valuable Professional

#2
11manish Profile Picture

11manish 209 Super User 2026 Season 2

#3
MS.Ragavendar Profile Picture

MS.Ragavendar 150 Super User 2026 Season 2

Last 30 days Overall leaderboard