cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Shafeel_07
Advocate I
Advocate I

PowerApps Optimize Query

Hi PowerApps Community,

 

Not too sure if you would be able to help but is there a way i can optimize the code below, its running super slow and was wondering if there is a way to speed it up . so pretty much what this code is doing is checking if the users full name is in a list then it will display all results else if the user name isnt in that list then it will display specific results or another set of specific results.  i know the code is really complex but any help to make it run faster would be great ! 

 

If(User().FullName in '[source]'.Staff_Name, SortByColumns(Search('[source]',Dropdown2_1.Selected.Value,"Source_Name"),"Source_Name"), Filter(SortByColumns(Search('[source]',Dropdown2_1.Selected.Value,"Source_Name"),"Source_Name"),LookUp('[source]', Name = Source_Name && (Business_Owner = User().FullName || Support_Contact = User().FullName || Support_Contact_2 = User().FullName), Name) in Source_Name Or Source_Name in ForAll(Filter('[source]',Data_Integrity_Test_Case_Id in ForAll(ForAll('[source]', LookUp('[source]', Data_Integrity_Test_Case_Id = Test_Case_Guid)),LookUp('[source]',Source_Name = Name && Business_Owner = User().FullName || Support_Contact = User().FullName || Support_Contact_2 = User().FullName,Test_Case_Guid))).Data_Integrity_Systems_Id,LookUp('[source]', Source_Guid= Data_Integrity_Systems_Id, Name))))

 

Or even just this part of the code 

 

Filter(SortByColumns(Search('[source]',Dropdown2_3.Selected.Value,"Source_Name"),"Source_Name"),Source_Name in ForAll(Filter('[source]',Data_Integrity_Test_Case_Id in ForAll(ForAll('[source]', LookUp('[source]', Data_Integrity_Test_Case_Id = Test_Case_Guid)),LookUp('[source]',Source_Name = Name && Business_Owner = User().FullName || Support_Contact = User().FullName ||Support_Contact_2 = User().FullName,Test_Case_Guid))).Data_Integrity_Systems_Id,LookUp('[source]', Source_Guid= Data_Integrity_Systems_Id, Name)))

 

Thanks in advance! 

1 ACCEPTED SOLUTION

Accepted Solutions
v-yuxima-msft
Community Support
Community Support

Hi @Shafeel_07 ,

 

Do you want to the query run faster?

I think you can use variable to have a try  and test it whether this method is ok.

 

In the OnStart you can create a variable that User() record and then you can use the variable in the Filter. Here is an example of what you can add to the OnStart.

Note that in design mode the OnStart is only triggered when the app is first loaded, so you will need to save, close and re-open the app to get the variable set after making the change.

 

Set(gvCurrentUser, User())

Then in your formula expression change "User()" to "gvCurrentUser".

 

These blogs may be helpful for you:

 

https://baizini-it.com/blog/index.php/2018/01/11/powerapps-caching-lookup-tables-to-improve-performa...

 

https://powerapps.microsoft.com/en-us/blog/enjoy-faster-startup-times-with-the-new-concurrent-functi...

 

more details about optimize in powerapps:

Optimize canvas-app performance in PowerApps

 

 

Hope this can be helpful.

Best Regards.

Yumia

 

View solution in original post

2 REPLIES 2
v-yuxima-msft
Community Support
Community Support

Hi @Shafeel_07 ,

 

Do you want to the query run faster?

I think you can use variable to have a try  and test it whether this method is ok.

 

In the OnStart you can create a variable that User() record and then you can use the variable in the Filter. Here is an example of what you can add to the OnStart.

Note that in design mode the OnStart is only triggered when the app is first loaded, so you will need to save, close and re-open the app to get the variable set after making the change.

 

Set(gvCurrentUser, User())

Then in your formula expression change "User()" to "gvCurrentUser".

 

These blogs may be helpful for you:

 

https://baizini-it.com/blog/index.php/2018/01/11/powerapps-caching-lookup-tables-to-improve-performa...

 

https://powerapps.microsoft.com/en-us/blog/enjoy-faster-startup-times-with-the-new-concurrent-functi...

 

more details about optimize in powerapps:

Optimize canvas-app performance in PowerApps

 

 

Hope this can be helpful.

Best Regards.

Yumia

 

View solution in original post

Thank you sooo much !!! ,  This has helped alot !! 

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

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

Power Apps June 2021

June Power Apps Community Call

Don't miss the call this month on June 16th - 8a PDT

Top Solution Authors
Top Kudoed Authors
Users online (19,520)