Showing results for 
Search instead for 
Did you mean: 
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"))






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.

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.


Any idea how to achieve this ?

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

Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

365 EduCon 768x460.png

Microsoft 365 EduCon

Join us for two optional days of workshops and a 3-day conference, you can choose from over 130 sessions in multiple tracks and 25 workshops.

Users online (1,582)