cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
MonsFabz
Frequent Visitor

Combining filter & search functions to view items in gallery

Hello there, 

I need your help for my App.

On the Data, Items property of my gallery (Excel file, multiple columns containing text), I firstly applied a formula that by default showed all items but with a search function allowing the user to look for specific items by typing a text in a searchcase (textinput label).

 

 

 

 

SortByColumns(Search(Table1, TextInput.Text,"Column1", "Column2", "Column3"), "Column1", If(SortDescending1, Descending, Ascending))

 

 

 

 

The problem is we had too many results because the search function searches anywhere within the columns. I could use Startswith function but it would narrow down the results too much.

So, what I want to achieve is start with a Startswith function on 1 column (Column1) and if we get no result apply the search function on all columns (Column1, Column2, Column3).

My code would be the following but doesn't work. Could you help me please. I don't know what i'm getting wrong :

 

 

 

 

If(IsEmpty(Filter(Table1, StartsWith(Column1, TextInput.Text))), Search(Table1,TextInput.Text, "Column1", "Column2", "Column3"))

 

 

 

 

Thanx

3 REPLIES 3
eka24
Super User III
Super User III

I made i test with the following which works:

If(CountRows(Filter(Applcication, StartsWith(Employee, TextInput3.Text)))=0,
Search(Applcication,TextInput3.Text, "Department", "Description", "Customer"),
Filter(Applcication, StartsWith(Employee, TextInput3.Text)))

------------

If you like this post, give a Thumbs up. Where it solved your request, Mark it as a Solution to enable other users find it.

MonsFabz
Frequent Visitor

Hello eka24,

Your code works but what I want to achieve is now clearer. 

I would like the gallery to display all items, sorted on the column "Afkorting", with a search function based on a textinput label and searching in 3 columns (Afkorting, Abréviation, Woorduitleg). Following code do the trick perfectly.

 

SortByColumns(Search(Table1, TextInput.Text,"Afkorting", "Abréviation", "Woorduitleg"), "Afkorting", If(SortDescending1, Descending, Ascending))

 

 But I would like the gallery to show first items corresponding the most to the text of the search. See example below, i typed "BAGP" in the search box. Three items contain the text BAGP (here : 1BAGP, ABAGP & BAGP). The third item for example matches completely the request but appears only on third position. I would like it to be the first item displayed, than the others.

QuestionBagp.png

Any idea how to achieve this ?

eka24
Super User III
Super User III

What you are trying to do is to sort the Table based on what you enter in the TextBox. Am not aware of this could be achieved.

------------

If you like this post, give a Thumbs up. Where it solved your request, Mark it as a Solution to enable other users find it.

Helpful resources

Announcements
PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

MBAS Attendee Badge

Claim Your Badge & Digital Swag!

Check out how to claim yours today!

secondImage

Are Your Ready?

Test your skills now with the Cloud Skill Challenge.

secondImage

Demo Extravaganza is Back!

We are excited to announce that Demo Extravaganza for 2021 has started!

MBAS on Demand

Microsoft Business Applications Summit sessions

On-demand access to all the great content presented by the product teams and community members! #MSBizAppsSummit #CommunityRocks

Top Solution Authors
Top Kudoed Authors
Users online (34,775)