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
Super User

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.

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
Super User

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
Microsoft 365 Conference – December 6-8, 2022

Microsoft 365 Conference – December 6-8, 2022

Join us in Las Vegas to experience community, incredible learning opportunities, and connections that will help grow skills, know-how, and more.

Difinity Conference 2022

Difinity Conference 2022

Register today for two amazing days of learning, featuring intensive learning sessions across multiple tracks, led by engaging and dynamic experts.

European SharePoint Conference

European SharePoint Conference

The European SharePoint Conference returns live and in-person November 28-December 1 with 4 Microsoft Keynotes, 9 Tutorials, and 120 Sessions.

Power Apps Ideas

Changes to Ideas Coming

We are excited to announce a new way to share your ideas for Power Apps!

Top Solution Authors
Top Kudoed Authors
Users online (1,886)