Showing results for 
Search instead for 
Did you mean: 

How do you Filter / Search SQL data returned from a prior search?

Hi I'm new to PowerApps and trying to learn as I go.


I have an application where I am doing a search on a SQL Table to return records based on who is logged in and that part works.  Now I want to either do another search based on those returned results or filter of those results based on what someone is searching on in a text box.

I've tried filter when using on prem-SQL and the results take forever so I went with search statement instead and it's much much quicker.  Is there something wrong in my filter statement? or is filter that much slower than search?

Here is the formula I'm using on Items to display in a gallery.


Filter Function: (Very Slow) but it returns data based on OwnerName who is logged in

Filter('[dbo].[Test]',Lower(OwnerName) = Lower(Office365Users.MyProfile().DisplayName))


Search Function to display same data (Much Faster)


I get results back in the gallery but now I want to add a search box that will search / filter the first results returned.

So the search is first on Owner Name but that might return 400 rows and to limit that further I want a search box that a user could type information in that would further filter this data down so it's more usable.

This is all tied back to a SQL on-premise backend.

Any suggestions or help would be greatly appreciated.

Super User II
Super User II

Re: How do you Filter / Search SQL data returned from a prior search?

You can easily fix the performance issue with the filter by changing a couple of things.


Create a variable in the OnStart of the App or OnVisible of the Screen that will hold the user's name:

Set(gvUserDisplayName, Lower(Office365Users.MyProfile().DisplayName))


Then change filter formula to 

Filter('[dbo].[Test]',Lower(OwnerName) = gvUserDisplayName)


This should improve performance by only making one call to Office365Users.MyProfile() instead of one call for each row being required. 


You can add additional search functionality by wrapping the search function around the filter:

Search(Filter('[dbo].[Test]',Lower(OwnerName) = gvUserDisplayName), SearchInput.Text, "ColumnName")


SearchInput would need to be changed to the name of your search box and ColumnName would need to be changed to the SQL column you want to search. If the search box is empty it should just return what the Filter() is returning.


If this post helps answer your question, please click on “Accept as Solution” to help other members find it more quickly. If you thought this post was helpful, please give it a Thumbs Up.

Helpful resources

Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

Power Platform ISV Studio

Power Platform ISV Studio

ISV Studio is designed to become the go-to Power Platform destination for ISV’s to monitor & manage published applications.


Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Tech Marathon

Maratón de Soluciones de Negocio Microsoft

Una semana de contenido con +100 sesiones educativas, consultorios, +10 workshops Premium, Hackaton, EXPO, Networking Hall y mucho más!

Top Solution Authors
Top Kudoed Authors
Users online (6,880)