Skip to main content
Community site session details

Community site session details

Session Id : SCWHUbNEOURjEImMkOmIhg
Power Apps - Building Power Apps
Answered

Search, Filter a gallery based on any keyword in a sentence

Like (0) ShareShare
ReportReport
Posted on 26 Sep 2020 05:45:14 by 9

Hey team,

 

Sorry just getting back into PowerApps and this is a simple one for some smart person out there!

 

Goal:

I have a gallery I'm trying to filter based off keywords I've set in a SharePoint list (HelpDeskHowTo).

 

Issue:

I've got it to work with search and filter but it will only work if my keyword appears as the first word in the text input box. If my keyword is "apply" then if i type "i want to apply" it wont show but just typing "apply" it will, if i type "Apply for" it will disappear. I need it to filter if my keyword shows up anywhere in the sentence

 

Examples below

 

This works

 

SS1.PNG

 

 

 

 

 

 

This doesn't

SS2.PNG

 

 

I've tried: 

Search(HelpDeskHowTo,DataCardValue1.Text, "Keywords")

Filter(HelpDeskHowTo, DataCardValue1.Text in Keywords)

 

Any help would be greatly appreciated 

Categories:
  • mauvaldesb Profile Picture
    2 on 03 Nov 2022 at 04:11:02
    Re: Search, Filter a gallery based on any keyword in a sentence

    Hi Rizzle1,

     

    I've tried using your code, however, I can't make it work. This is what my code looks like:

     

    Filter(
     Questions,
     Sum(
     ForAll(
     Filter(Split(TxtInput_Question.Text, " "), Len(Trim(Result)) > 0),
     If(Result in "Shortdescription", 1, 0)
     ),
     Value) > 0
    )

     

    Any idea of what may be wrong?

     

    Thank you

  • v-yutliu-msft Profile Picture
    on 28 Sep 2020 at 06:01:01
    Re: Search, Filter a gallery based on any keyword in a sentence

    Hi @Rizzle1 ,

    Do you have any other problem?

    If not, could you change your issue's status to "Answered"?

    Thanks!

     

     

    Best regards,

  • Verified answer
    Rizzle1 Profile Picture
    9 on 26 Sep 2020 at 19:39:55
    Re: Search, Filter a gallery based on any keyword in a sentence

    Ok I've managed to figure it out thanks to the information here

     

    "There is no direct way to do what you want, but we can create an expression that could get to that. It will be something along the lines of:

    Filter(
     Projects,
     Sum(
     ForAll(
     Filter(Split(SearchBox.Text, " "), Len(Trim(Result)) > 0),
     If(Result in Details, 1, 0)),
     Value) > 0)

    Let's go through it. This sub-expression:

    Filter(Split(SearchBox.Text, " "), Len(Trim(Result)) > 0)

    It splits down your search text box into words, and also removes any empty words which you would get if you had two spaces between the words or leading or trailing spaces.

    Then, for all words that were split, we see if that word is contained in the Details column of your list; if so we get the value 1, and 0 otherwise. The result of the ForAll sub-expression is a list of values corresponding to each the items in Projects. We then Sum those values. If any of the words from the search box were present in the details, then the sum will be greater than 0.

    Finally we can filter the Projects based on that value, which should give you the result you want.

    "

     

    Filter(
    HelpDeskHowTo,
    Sum(
    ForAll(
    Filter(Split(searchQuery, " "), Len(Trim(Result)) > 0),
    If(Result in Keywords, 1, 0)),
    Value) > 0)

     

    I think the combination of split and setting a number to a value if it matches then filtering off that has done the trick.

    I've now set my text input box to set the searchQuery variable on change so its working beautifully

  • Rizzle1 Profile Picture
    9 on 26 Sep 2020 at 18:11:37
    Re: Search, Filter a gallery based on any keyword in a sentence

    Thank you for the reply @WarrenBelz 

     

    Thanks for the advice, I'm fine with these being non Delegable as I don't think my dataset will ever grow over 200 items

     

    So I'm wanting the formula to be able to search the entire string looking for keywords not just the first word.

     

    Example: I need to apply for leave

    Apply is a keyword I've set on a list item as makeshift metadata. I want this item to show if apply is anywhere in the string

     

    Currently it only works if I type apply by itself, if I put "apply for leave" (with a space and words after) it will no longer match and my recommendation disappears

  • WarrenBelz Profile Picture
    148,894 Most Valuable Professional on 26 Sep 2020 at 10:43:40
    Re: Search, Filter a gallery based on any keyword in a sentence

    Hi @Rizzle1 ,

    Firstly, both syntaxes you have supplied work if “apply” or part of it, is the only input in the text box, but please note neither are Delegable.

    If I am reading your requirements right, you want to type apply, but then something after it and still have it match? It is not possible to have any “any part matches any part” search. Is this what you are meaning?

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

Announcing our 2025 Season 2 Super Users!

A new season of Super Users has arrived, and we are so grateful for…

Paul Stork – Community Spotlight

We are honored to recognize Paul Stork as our July 2025 Community…

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 791 Most Valuable Professional

#2
MS.Ragavendar Profile Picture

MS.Ragavendar 410 Super User 2025 Season 2

#3
mmbr1606 Profile Picture

mmbr1606 275 Super User 2025 Season 2

Loading started