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

Free search using a text input

Say I have a the following data table:
"Pet_Type"    "Pet_Name "    "Owner"
Dog                Buster             Adam

Cat                 Mushroom      Becky

Toucan           Rocko              Chris

 

I'm trying to use one text input line to search on all three columns. I want it so that if I enter to the text input control: "og hri", the data table should display the Dog and Chris rows. Currently I've got a gallery populated by splitting the input text by spaces, like

Split(SearchInput.Text, " ")

Then, I filter the pet table by

Filter('Pets',IsBlank(SearchInput)||Title.Text in Pet_Type||Title.Text in Pet_Name||Title.Text in Owner)

But when I put in "Dog Chris", it behaves very eratically, sometimes only showing the dog row, or chris row, or none at all. Once or twice I just had "Dog" and it showed nothing.

1 ACCEPTED SOLUTION

Accepted Solutions
Super User
Super User

Re: Free search using a text input

@epiej 

If you are just doing a free text search over all the data, then I believe the following formula might be what you are looking for:

Filter(Pets, 
       (Sum(Split(SearchInput.Text, " "), If(Result in Pet_Type,1))>0) 
     || Sum(Split(SearchInput.Text, " "), If(Result in Pet_Name,1))>0
     || Sum(Split(SearchInput.Text, " "), If(Result in Owner,1))>0
     )

If you want to tidy it up a bit, you could do something like this as well:

Filter(AddColumns(Pets, "allData", Pet_Type & " " & Pet_Name & " " & Owner), 
       (Sum(Split(TextInput4.Text, " "), If(Result in allData,1))>0) 
)

Or, for even more tidy:

Filter(AddColumns(Pets, "allData", Concat([Pet_Type, Pet_Name, Owner], Value & " ")), 
       (Sum(Split(TextInput4.Text, " "), If(Result in allData,1))>0) 
)

I hope this is helpful for you.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.
3 REPLIES 3
Super User
Super User

Re: Free search using a text input

@epiej 

If you are just doing a free text search over all the data, then I believe the following formula might be what you are looking for:

Filter(Pets, 
       (Sum(Split(SearchInput.Text, " "), If(Result in Pet_Type,1))>0) 
     || Sum(Split(SearchInput.Text, " "), If(Result in Pet_Name,1))>0
     || Sum(Split(SearchInput.Text, " "), If(Result in Owner,1))>0
     )

If you want to tidy it up a bit, you could do something like this as well:

Filter(AddColumns(Pets, "allData", Pet_Type & " " & Pet_Name & " " & Owner), 
       (Sum(Split(TextInput4.Text, " "), If(Result in allData,1))>0) 
)

Or, for even more tidy:

Filter(AddColumns(Pets, "allData", Concat([Pet_Type, Pet_Name, Owner], Value & " ")), 
       (Sum(Split(TextInput4.Text, " "), If(Result in allData,1))>0) 
)

I hope this is helpful for you.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.
Community Support Team
Community Support Team

Re: Free search using a text input

Hi @epiej ,

 

Do you test with @RandyHayes 's solution, I test on my side and it works ok. 

And I will accept it as solution.

20190514SearchByTextInput1.PNG

 

Best Regards.

Yumia

Highlighted
epiej
Level: Powered On

Re: Free search using a text input

This works great, thank you!

Helpful resources

Announcements
firstImage

Watch Sessions On Demand!

Continue your learning in our online communities.

SecondImage

PowerApps Monthly Community Call

Next Wednesday, September 18th at 8am PDT

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

SecondImage

Power Platform Summit North America

Register by September 5 to save $200

Top Kudoed Authors
Users Online
Currently online: 35 members 4,545 guests
Please welcome our newest community members: