cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
bees
Regular Visitor

Searching with multiple key words

Hi, I'm building an app that will eventually be a searchable databse of undergraduate theses. At the moment I'm using the template provided by powerapps which is actually very similar to the style of databse I had envisaged. 

 

I'm having an issue with the search box. Ideally I would like to be able to enter multiple search terms seperated by a comma or even just a space which returns all cases that contain these terms. The search function I have come up with based on information in these forums is:

SortByColumns(Search(Table1_1,TextSearchBox1.Text,"Abstract","Author","Supervisor(s)","Project_x0020_Title"),
"Year", If(SortDescending1, Descending, Ascending))

 

When I enter a term like "biofilm" in the box it searches the columns "Abstract","Author","Supervisor(s)" and "Project Title" and returns any case containing the word biofilm in these 4 columns.

 

This is great but ideally I would like to be able to enter multiple search terms in the text box, for example "biofilm", "Smith", "ecotoxicology" to return any cases which contain these three words. Is this possible to do in Powerapps? At the moment if I enter multiple terms and the words aren't consecutive then the search returns a blank. So for example if I enter "john" "smith", projects by john smith are returned; however if I enter "smith" "ecotoxicology" then there is no cases returned.

 

Thanks!

 

 

38 REPLIES 38
v-monli-msft
Community Support
Community Support

Hi @bees,

 

I'm afraid that this cannot be achieved so far in PowerApps. Please consider to add an idea here:

https://powerusers.microsoft.com/t5/PowerApps-Ideas/idb-p/PowerAppsIdeas

 

Regards,

Mona Li

Community Support Team _ Mona Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

This can be done with some creativity!  If you want to generate a collection of the records that contain ALL of the keywords you specify (in a textbox separated by a space, in my example) for a certain column, the code below will get what you seek:

Filter(
    CollectionName,
    IsBlank(
        Find(
            "0",
            Concat(
                Filter(
                    Split(
                        SearchBox.Text,
                        " " //or any delimiter.
                    ),
                    !IsBlank(ThisRecord.Value)
                ),
                If(
                    TrimEnds(ThisRecord.Value) in ColumnName1 || TrimEnds (ThisRecord.Value) in ColumnName2, // etc.
                    "1",
                    "0"
                )
            )
        )
    )
)

Here's what the code is doing:  Basically, we split the keywords you inputed using the space character as the delimiter (you could adjust this to be a comma or semicolon or whatever).  Then, for each record of the collection, we either include it or filter it out based on a string of zeros and ones we build, based on the keywords; "0" if a keyword is not found, and "1" if it is found.  We only want to include records that gave a string of all "1" 's.  So the condition on our filter is "IsBlank(Find("0", ....))  since the PowerApp Find function returns "Blank" (not 0) when a substring is not found.

If you wanted a collection of records that contain ANY of the keywords you specify, you could modify the Filter criteria from IsBlank(Find("0"...  to Find("1", ... ) > 0

I hope this helps someone!  While many features are not explicitly built into PowerApps (although the list is growing) it's kind of like they give us Yellow, Blue, and Red crayons from which we must blend all the colours we need for our drawing.  @v-monli-msft perhaps there as been a built-in way to search for multiple keywords since the OP asked this question in 2017, not sure.  Either way, it's fun to think of workarounds.

Hi

I have shared in Facebook in my group "Working with Powerapps" before.
Here is the sample and workable formula.

I use Split, Search, Filter, Last, First and TrimEnds and get exactly what clients want.
Simple and straight as all functions are explicitly self explanatory.

Please take note that you can enter keyword in any sequence. Not necessary to follow the fields sequence in the formula. It will search whatever matching keywords, and in partial. That's the reason I use search. You can modify to use IF and Number of columns to iterate so that formula becomes shorter.

My formula used for my client. Add more as necessary based on number of fields. Modify as you wish.

If(IsBlank(TextInput2), MyTable, Search(Search(Search(Search(MyTable, First(TrimEnds(Split(TextInput2.Text, ","))).Result, "Name", "City", "State", "Country"), Last(FirstN(TrimEnds(Split(TextInput2.Text, ",")), 2)).Result, "Name", "City", "State", "Country"), Last(FirstN(TrimEnds(Split(TextInput2.Text, ",")),3)).Result, "Name", "City", "State", "Country"), Last(FirstN(TrimEnds(Split(TextInput2.Text, ",")),4)).Result, "Name", "City", "State", "Country"))

Enjoy my sharing and have a nice day.

Thanks @PK_Hong for sharing!  That solution certainly works if you know both the number of keywords you wish to search for, and also the number of results you wish to display.  I love the First(LastN( way of indexing the results, I've used that as well in many situations!  I prefer a dynamic approach, where the number of keywords is not limited and the returned result is the entire collection of all records that contained the keywords (rather than only the top N).  These could be displayed in a listbox or gallery.  But like all code.. if it works for your purposes it's the right code!

HI @CalfordMath 

 

Hi Thanks for sharing of info.

As I mentioned, you can use n= n+1 iteration to make it more user friendliness. I love your way of writing which serves for one fields.

Maybe you can also try mines which is Multi Fields, Multi Keywords and instant (I use my own custom connector, not SPL or CDS).

 

I wish you can integrate mine and make it better and share here. I am more than happy to use a shorter and better codes from others with sharing.

 

Best wishes

Additional Notres

 

Even it is N fields, all keywords are searched for... it has no limit!

The only limitation is if you have more fields, you need to add more "field name".

 

Anyway this is my initial formula.

For my own, I am using dynamic iteration. I do not need to add one by one

So this is for veryone to expand ideas.

 

Thanks so much for sharing.

True @PK_Hong my solution was only for a single field search.  It could be modified with a simple "Or" to look at more fields:

TrimEnds(Result) in Column1 ||TrimEnds(Result) in Column2 || TrimEnds(Result) in Column3 ...

It would be really nice if the Search function allowed us to pass a collection of strings, rather than just a single string.  I suppose it would need to be told whether to report records containing 'any' or 'all' of the search terms.  I haven't tried to re-work your method using an iterative approach, but when I have some time I'll give it a go.

 

I was looking to see if there was way to search in all columns rather than having to explicitly list each one by name... no such luck, but in the process, I did discover that using the "in" operator for a sub-string test is case-insensitive, which means I probably could remove the Lower() calls from my code to clean it up a bit.

It is a pleasure talking through these ideas with you!  I love how the PowerApps community shares workarounds and tricks.  The platform is still so young and growing.. it's fun to be near the forefront of something 😉

 

This was an absolute lifesaver! I've been searching for days, literally and kept coming across a link referenced on these forums that has access denied. It's crazy to me how much simpler these formulas are than those I was experimenting with. I have never worked with the TrimEnds operator before, nor would've thought about identifying the results with a 1 or 0. Anyway, I can't thank you both enough for providing your solutions!

@CalfordMath - After implementing your solution I'm just now realizing that I need to also have something so that it knows which row I select with a filtered result. I didn't realize (as I wasn't focused on the actual data) that when I click on a row that's filtered from this search it always shows me the first row in the gallery. Obviously this is NOT what we want for the behavior. My form is currently doing a lookup to the selected gallery item - Lookup(datasource, ID = gallery.selected.id), but with using the TrimEnds(Result) function I'm guessing we need to have something in the form that looks to that result vs what I have in there. Things work fine for selecting an item in the gallery if I don't use search to filter, but we need to have it show the selected item in either case.

 

*EDIT* to clarify I am seeing the right one for a split second on the form screen but it changes back to the first row item. So, something is causing the form to then go to the first item in the list.

 

Your help is greatly appreciated!

Helpful resources

Announcements

Community will be READ ONLY July 16th, 5p PDT -July 22nd

Dear Community Members,   We'd like to let you know of an upcoming change to the community platform: starting July 16th, the platform will transition to a READ ONLY mode until July 22nd.   During this period, members will not be able to Kudo, Comment, or Reply to any posts.   On July 22nd, please be on the lookout for a message sent to the email address registered on your community profile. This email is crucial as it will contain your unique code and link to register for the new platform encompassing all of the communities.   What to Expect in the New Community: A more unified experience where all products, including Power Apps, Power Automate, Copilot Studio, and Power Pages, will be accessible from one community.Community Blogs that you can syndicate and link to for automatic updates. We appreciate your understanding and cooperation during this transition. Stay tuned for the exciting new features and a seamless community experience ahead!

Summer of Solutions | Week 4 Results | Winners will be posted on July 24th

We are excited to announce the Summer of Solutions Challenge!   This challenge is kicking off on Monday, June 17th and will run for (4) weeks.  The challenge is open to all Power Platform (Power Apps, Power Automate, Copilot Studio & Power Pages) community members. We invite you to participate in a quest to provide solutions in the Forums to as many questions as you can. Answers can be provided in all the communities.    Entry Period: This Challenge will consist of four weekly Entry Periods as follows (each an “Entry Period”)   - 12:00 a.m. PT on June 17, 2024 – 11:59 p.m. PT on June 23, 2024 - 12:00 a.m. PT on June 24, 2024 – 11:59 p.m. PT on June 30, 2024 - 12:00 a.m. PT on July 1, 2024 – 11:59 p.m. PT on July 7, 2024 - 12:00 a.m. PT on July 8, 2024 – 11:59 p.m. PT on July 14, 2024   Entries will be eligible for the Entry Period in which they are received and will not carryover to subsequent weekly entry periods.  You must enter into each weekly Entry Period separately.   How to Enter: We invite you to participate in a quest to provide "Accepted Solutions" to as many questions as you can. Answers can be provided in all the communities. Users must provide a solution which can be an “Accepted Solution” in the Forums in all of the communities and there are no limits to the number of “Accepted Solutions” that a member can provide for entries in this challenge, but each entry must be substantially unique and different.    Winner Selection and Prizes: At the end of each week, we will list the top ten (10) Community users which will consist of: 5 Community Members & 5 Super Users and they will advance to the final drawing. We will post each week in the News & Announcements the top 10 Solution providers.  At the end of the challenge, we will add all of the top 10 weekly names and enter them into a random drawing.  Then we will randomly select ten (10) winners (5 Community Members & 5 Super Users) from among all eligible entrants received across all weekly Entry Periods to receive the prize listed below. If a winner declines, we will draw again at random for the next winner.  A user will only be able to win once overall. If they are drawn multiple times, another user will be drawn at random.  Individuals will be contacted before the announcement with the opportunity to claim or deny the prize.  Once all of the winners have been notified, we will post in the News & Announcements of each community with the list of winners.   Each winner will receive one (1) Pass to the Power Platform Conference in Las Vegas, Sep. 18-20, 2024 ($1800 value). NOTE: Prize is for conference attendance only and any other costs such as airfare, lodging, transportation, and food are the sole responsibility of the winner. Tickets are not transferable to any other party or to next year’s event.   ** PLEASE SEE THE ATTACHED RULES for this CHALLENGE**   Week 1 Results: Congratulations to the Week 1 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge. Community MembersNumber of SolutionsSuper UsersNumber of Solutions @anandm08  23 @WarrenBelz  31 @DBO_DV  10 @Amik  19 AmínAA 6 @mmbr1606  12 @rzuber  4 @happyume  7 @Giraldoj  3@ANB 6 (tie)   @SpongYe  6 (tie)     Week 2 Results: Congratulations to the Week 2 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge. Community MembersSolutionsSuper UsersSolutions @anandm08  10@WarrenBelz 25 @DBO_DV  6@mmbr1606 14 @AmínAA 4 @Amik  12 @royg  3 @ANB  10 @AllanDeCastro  2 @SunilPashikanti  5 @Michaelfp  2 @FLMike  5 @eduardo_izzo  2   Meekou 2   @rzuber  2   @Velegandla  2     @PowerPlatform-P  2   @Micaiah  2     Week 3 Results: Congratulations to the Week 3 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge.   Week 3:Community MembersSolutionsSuper UsersSolutionsPower Apps anandm0861WarrenBelz86DBO_DV25Amik66Michaelfp13mmbr160647Giraldoj13FLMike31AmínAA13SpongYe27     Week 4 Results: Congratulations to the Week 4 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge.   Week 4:Community MembersSolutionsSuper UsersSolutionsPower Apps DBO-DV21WarranBelz26Giraldoj7mmbr160618Muzammmil_0695067Amik14samfawzi_acml6FLMike12tzuber6ANB8   SunilPashikanti8

Check Out | 2024 Release Wave 2 Plans for Microsoft Dynamics 365 and Microsoft Power Platform

On July 16, 2024, we published the 2024 release wave 2 plans for Microsoft Dynamics 365 and Microsoft Power Platform. These plans are a compilation of the new capabilities planned to be released between October 2024 to March 2025. This release introduces a wealth of new features designed to enhance customer understanding and improve overall user experience, showcasing our dedication to driving digital transformation for our customers and partners.    The upcoming wave is centered around utilizing advanced AI and Microsoft Copilot technologies to enhance user productivity and streamline operations across diverse business applications. These enhancements include intelligent automation, AI-powered insights, and immersive user experiences that are designed to break down barriers between data, insights, and individuals. Watch a summary of the release highlights.    Discover the latest features that empower organizations to operate more efficiently and adaptively. From AI-driven sales insights and customer service enhancements to predictive analytics in supply chain management and autonomous financial processes, the new capabilities enable businesses to proactively address challenges and capitalize on opportunities.    

Updates to Transitions in the Power Platform Communities

We're embarking on a journey to enhance your experience by transitioning to a new community platform. Our team has been diligently working to create a fresh community site, leveraging the very Dynamics 365 and Power Platform tools our community advocates for.  We started this journey with transitioning Copilot Studio forums and blogs in June. The move marks the beginning of a new chapter, and we're eager for you to be a part of it. The rest of the Power Platform product sites will be moving over this summer.   Stay tuned for more updates as we get closer to the launch. We can't wait to welcome you to our new community space, designed with you in mind. Let's connect, learn, and grow together.   Here's to new beginnings and endless possibilities!   If you have any questions, observations or concerns throughout this process please go to https://aka.ms/PPCommSupport.   To stay up to date on the latest details of this migration and other important Community updates subscribe to our News and Announcements forums: Copilot Studio, Power Apps, Power Automate, Power Pages

Users online (1,568)