cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
amelsom
Level: Powered On

Searching with multiple words in a text box

Hi,

 

I've been round and round in circles, on this. I have a sharepoint database that consists of the coloums:

First Name, Last Name, Department, Rating, Rate, Email, Number, County, Focal Point Ref. And i like the search box to be able to search through all of these and return results. Most of my users will search something like:

 

" James Smith Sound" or "Sound 200" or just "Video" 

 

I have tried loads of formulas and watched a few videos, and while i can get it to search all the coloums per word, i can't get it to search for multiple words. I would really appericate any helps i've be banging my head on this for the last 6 weeks. 

 

I have tried these formulas:

 

 Search( Freelancers, SearchBox.Text, "First_x0020_Name", "Last_Name", "Rating", "Department" )

Filter( Freelancers, StartsWith( First_x0020_Name, SearchBox.Text ) || StartsWith( Last_Name, SearchBox.Text ) )

With the above code, soon as i place space in the search box all results vanish, so its not searching multiple text inputs. 

 

And also have tried this one from Carlos on another post.

 

Spoiler
Filter(
AddColumns(
Freelancers,
"present",
Sum(
ForAll(
Split(SearchBox.Text, " "),
If(IsBlank(Find(Result, Text)), 0, 0)
),
Value
)
),
present = CountRows(Split(SearchBox.Text, " "))
)

With this i changed the the 0, 0 to different variations and have the same issue its not searching all strings, and all frields in the table. 

 

I have tried a basic version:

 

Search(DataCatalogueList, searchKW.Text, "keyword", "keyword2", "keyword3", "keyword4", "keyword5", "keyword6", "keyword7", "keyword8", "keyword9", "keyword10")

And have the same space issue i have also tried:

 

SortByColumns(
Filter(
Search(
Freelancers,
SearchBox.Text,
"First_x0020_Name", "Last_Name"),
StartsWith(First_x0020_Name, SearchBox.Text),
First_x0020_Name = false),
"Rate",
If(SortDescending1, Descending, Ascending))

Buti get an error on the ending If statement :

 If(SortDescending1, Descending, Ascending))

 Which just says the "if" statement has some invalid arguments, i get this on all the different variations of filter and search i've looked at on the If(Sortdescending etc) code. 

 

I am fairly new to Powerapps as well so i may just be missing some arguments or syntax on the code.

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
jag75
Level: Powered On

Re: Searching with multiple words in a text box

"But i can't figure out how to make sure the table displays all the listings before something is entered in the search box"

Wrap it in an If( !IsBlank()) like below:

If(     
     !isBlank(SearchBox.Text) ,          
                  SortByColumns(Filter(Freelancers,SearchBox.Text in First_x0020_Name & " " & Last_Name & " " &                  Department & " " & Rating & " " & County), "First_x0020_Name",Ascending)
      , Freelancers)

 

 

7 REPLIES 7
amelsom
Level: Powered On

Re: Searching with multiple words in a text box

Just to update i have managed to get this code searching both first and last name but it does not accept spaces, so i can either seach.

 

James and get James Smith, or

Smith and get James Smith

 

If i search James Smith, i get no results.

 

SortByColumns(Filter(Freelancers,SearchBox.Text in First_x0020_Name & Last_Name), "First_x0020_Name",Ascending)
amelsom
Level: Powered On

Re: Searching with multiple words in a text box

Another update

 

I have got his working as i needed now accepting spaces with this code:

 

SortByColumns(Filter(Freelancers,SearchBox.Text in First_x0020_Name & " " & Last_Name & " " & Department & " " & Rating  & " " & County), "First_x0020_Name",Ascending)

But i can't figure out how to make sure the table displays all the listings before something is entered in the search box

jag75
Level: Powered On

Re: Searching with multiple words in a text box

"But i can't figure out how to make sure the table displays all the listings before something is entered in the search box"

Wrap it in an If( !IsBlank()) like below:

If(     
     !isBlank(SearchBox.Text) ,          
                  SortByColumns(Filter(Freelancers,SearchBox.Text in First_x0020_Name & " " & Last_Name & " " &                  Department & " " & Rating & " " & County), "First_x0020_Name",Ascending)
      , Freelancers)

 

 

amelsom
Level: Powered On

Re: Searching with multiple words in a text box

Thanks for the reply I get an error when using the !isBlank statement, and if i try just using if(isBlank(Searchbox.text), sortbycoloums etc that doesn't work and the search stops as well. Attached an image of the code in place showing the error.

 

Second time the error went away but it still doesn't show the results when the search box is blank

 

 

Edit: Just to check this code is placed under the Item tag. 

 

I tried putting a If(isBlank(Searchbox.text), true) in the visable tag, this works but only shows all entries when its blank, and soon as i type in the box it goes blank, even if the my orignal code is still in the Item tag. I'm guessing this is because its conflicting, and visable i taking preference. 

 

 

amelsom
Level: Powered On

Re: Searching with multiple words in a text box

Ok figured it all out, your code works, I was missing a massive oversight, my defult text in the search box was enabled so it was populating it with Search... which obviously means the box isn't blank so no results showed! Soon as i deleted the default text from the box it worked!


Thanks for your help!

Highlighted
KroonOfficeSol
Level 10

Re: Searching with multiple words in a text box

@amelsom

 

This way is better to show all.

SortByColumns(
	Filter(Freelancers
		, !IsBlank(SearchBox.Text) || Split(SearchBox.Text, "+") in First_x0020_Name & " " & Last_Name & " " & Department & " " & Rating  & " " & County
	)
	, "First_x0020_Name",Ascending
)

The split is optional and could make that someone can search for more words and only one off the words should be available.

 

Hope this helps.

 

Paul

amelsom
Level: Powered On

Re: Searching with multiple words in a text box

Thanks for the replies both solutions work really well

Helpful resources

Announcements
firstImage

Watch Sessions On Demand!

Continue your learning in our online communities.

SecondImage

PowerApps Monthly Community Call

Next Wednesday, August 21st at 8am PDT

Top Community Contributors for July 2019

Top Community Contributors for July 2019

Let's thank our top community contributors

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

FirstImage

Power Platform World Tour

Coming to a city near you

thirdimage

PowerApps Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

FourthImage

Join PowerApps User Group!!

Connect, share, and learn with your peers year-round

FifthImage

Dynamics 365 and Power Platform April 2019 Release notes

Features releasing from April 2019 through September 2019!

SixthImage

Power Summit Australia 2019

August 20-23rd 2019

Users Online
Currently online: 29 members 3,838 guests
Please welcome our newest community members: