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 / Search, Filter a galle...
Power Apps
Answered

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

(0) ShareShare
ReportReport
Posted on 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:
I have the same question (0)
  • WarrenBelz Profile Picture
    155,762 Most Valuable Professional on at

    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?

  • Rizzle1 Profile Picture
    9 on at

    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

  • Verified answer
    Rizzle1 Profile Picture
    9 on at

    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

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

    Hi @Rizzle1 ,

    Do you have any other problem?

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

    Thanks!

     

     

    Best regards,

  • mauvaldesb Profile Picture
    2 on at

    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

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 Launch!

Jump in, show your community spirit, and win prizes!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
Valantis Profile Picture

Valantis 491

#2
WarrenBelz Profile Picture

WarrenBelz 407 Most Valuable Professional

#3
11manish Profile Picture

11manish 331

Last 30 days Overall leaderboard