web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Powerapps super slow e...
Power Apps
Answered

Powerapps super slow even though I don't have many formulas in it. How can I make it leaner?

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

I have an edit form with a "submit" button that has the following instructions:

If(
Or(
And(Metrics_Gallery.Selected.'Goal type'="Less than", Value(MetricResult.Text)<=Value(Metrics_Gallery.Selected.Threshold)),
And(Metrics_Gallery.Selected.'Goal type'="More than", Value(MetricResult.Text)>=Value(Metrics_Gallery.Selected.Threshold)),
And(Metrics_Gallery.Selected.'Goal type'="Equal to", Value(MetricResult.Text)=Value(Metrics_Gallery.Selected.Threshold))),

Patch(SMCR,Metrics_Gallery.Selected,{Fail:"Pass"}),

Patch(SMCR,Metrics_Gallery.Selected,{Fail:"Fail"}))

;

SubmitForm(Form1)

 

And the the OnSuccess property of the editform:

Patch(SMCR,Metrics_Gallery.Selected,{Status:"Updated"})

;

Navigate('Home page V2')

 

Basically I'm asking it to evaluate if a metric "passes" o "fails" a certain criteria, and then I assign an status to that metric and submit the form, while assigning a "updated" status to it if the form is successful.

I though these were pretty straighforward instructions, but for some reason everytime that I try to submit the form powerapps takes almost 30 seconds loading and submitting the form. Is there any way in which I can fix this?

Categories:
  • Verified answer
    LaurensM Profile Picture
    12,516 Moderator on at

    Hi @Anonymous,

     

    There are some smaller improvements you can make by optimizing the current code. That being said, I was unable to recreate a slow SubmitForm submission - even the more complex saved after a couple of seconds. 

     

    Submit button OnSelect:

    SubmitForm(Form1)

     

    OnSuccess of the form:

    With(
     {wMetricResult: Value(MetricResult.Text), wMetricThreshold: Value(Metrics_Gallery.Selected.Threshold)},
     Patch(
     SMCR,
     Metrics_Gallery.Selected,
     {
     Status:"Updated",
     Fail: If(
     Or(
     And(Metrics_Gallery.Selected.'Goal type'="Less than", wMetricResult <= wMetricThreshold),
     And(Metrics_Gallery.Selected.'Goal type'="More than", wMetricResult >= wMetricThreshold),
     And(Metrics_Gallery.Selected.'Goal type'="Equal to", wMetricResult = wMetricThreshold)
     ),
     "Pass",
     "Fail"
     )
     }
     )
    );
    Navigate('Home page V2')

    Should it be possible in your case, you could try to run your If() function on the OnVisible of your screen so that the "Fail" or "Pass" is saved to a variable. This way you simply have to reference the variable in your Patch() - this is only possible if the Pass/Fail value does not change on your Form screen.

     

    If this solves your question, would you be so kind as to accept it as a solution & give it a thumbs up.

    Thanks!

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Hi Laurens! I just have two additional questions:

    1) Why are you writing the w in front of MetricResult? Sorry if this is very basic, I've never seen it written like that!

    2) What I'm trying to do is that if the metrics fails, then the comment section is mandatory, and the user shouldn't be able to submit the form if that field is blank. That's why I was trying to SubmitForm after evaluating the metric (I had a If function on the required property of the comment field). Where should I put this requirement in your solution?

  • LaurensM Profile Picture
    12,516 Moderator on at

    @Anonymous,

     

    1) I personally use the wVarName to clarify that this is a Local Variable in scope of the With() function. (w stands for With) 

    2) Wouldn't it be possible to use this logic within the Form itself? Use the following code in the 'Required' property of the Comment DataCard (not the textinput but the container around it):

     

    //Returns true if it fails
    !With(
     {wMetricResult: Value(MetricResult.Text), wMetricThreshold: Value(Metrics_Gallery.Selected.Threshold)},
     Or(
     And(Metrics_Gallery.Selected.'Goal type'="Less than", wMetricResult <= wMetricThreshold),
     And(Metrics_Gallery.Selected.'Goal type'="More than", wMetricResult >= wMetricThreshold),
     And(Metrics_Gallery.Selected.'Goal type'="Equal to", wMetricResult = wMetricThreshold)
     )
    )

     

    The Pass and Fail can be automatically filled in a similar logic. Here you will have to adjust the Default property (or DefaultSelectedItems in case of a Choice type) of the Fail DataCardValue. Adjust the Default property & make the DataCardValue DisplayMode.View so the user cannot change it.

     

    This way we can leave out that part of the OnSuccess logic.

     

    I hope this helps!

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Thank you!! I did what you suggested, and the app is working better. I also modified the gallery a bit, so now I'm not seeing all the rows at the same time, so maybe that also helped.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 234 Super User 2026 Season 2

#2
WarrenBelz Profile Picture

WarrenBelz 207 Most Valuable Professional

#3
timl Profile Picture

timl 122 Super User 2026 Season 2

Last 30 days Overall leaderboard