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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / What is the use of IfE...
Power Apps
Answered

What is the use of IfError?

(0) ShareShare
ReportReport
Posted on by

Hi Community,

Am I doing something wrong here:

HimanshuSSharma_0-1614347360014.png

 

It is essentially IfError(A/B,0) returning an error!!

BTW this is a case where B is 0 (#Div in Excel)

Thanks for your help!

Categories:
I have the same question (0)
  • RandyHayes Profile Picture
    76,297 Super User 2024 Season 1 on at

    @Anonymous 

    Beside the message in the formula editor (which is very often misleading), what issue are you seeing with the formula?  If should be returning the values of the two Text's divided, or a 0 if there is an error.

     

    If any part of the formula evaluates to blank, the formula editor will usually show that it can't evaluate the expression.  But, your end result in the app should be functional.

     

    I hope this is helpful for you.

  • Community Power Platform Member Profile Picture
    on at

    @RandyHayes So I am expecting a number value as output, and since the denominator is 0 I am expecting the result to be 0 as well (as the first fallback). My next logic says that if the value is 0, colour it blue which was not happening.

     

    You are correct in saying that if any formula evaluates to blank- because if I use If(IsBlankOrError(A/B),0,A/B) it gives me the correct result of colour blue, but it is suboptimal as I have to calculate twice.

    Maybe we need and IfBlankOrError to make IfError more useful??

  • Verified answer
    RandyHayes Profile Picture
    76,297 Super User 2024 Season 1 on at

    @Anonymous 

    If you're trying to set a color from this, then this formula should be giving you what you want:

    If(IfError(Value(Label_FYtblFcst_3.Text) / Value(Label_FytblFcst7.Text), 0) = 0, Blue, Green)

     

     

  • Community Power Platform Member Profile Picture
    on at

    @RandyHayes This helps, but I was trying to avoid doing calculation again.
    My logic was I had a label.text = IfError(Value(Label_FYtblFcst_3.Text) / Value(Label_FytblFcst7.Text), 0)

    and then

    if(label.text = 0, blue, green)

    This is returning green as when I check label.text in formula bar, it says "Powerapps encountered an error...."

    eventually ended up using If(IsBlankOrError(label.text),blue,label.text = 0, blue, green)  which seems to defeat the purpose of IfError, hence the question.

     

    Thanks!

  • RandyHayes Profile Picture
    76,297 Super User 2024 Season 1 on at

    @Anonymous 

    I'm not sure what you mean by doing it twice?  

    You are only doing the formula once and providing a default if there is an error, then setting a color based on that.


    If you need to know what the outcome was (in terms of was it blue or green) you can always reference your control by its color:

       If(yourControl.Fill = Green, "Yay!", "Boo!")

    Or whatever property you are setting the color on.

    No need for an extra label for this.

     

  • Tan_Jia_Ying Profile Picture
    54 on at

    Hi,

    I try to get five drop-down list is "ok" at the same time, and the result of the text label is "ok". But if one of the drop-down list is "Fail", then the result of the text label is "Fail".

     

    The program I wrote did not produce errors, but the results it produced were not what I wanted. I've set the following:

     

    Drop down: Items=

    ["OK","Fail"]

     

    Text Label: Text =

    IfError((Text(Dropdown6.SelectedText.Value)&&(Dropdown7.SelectedText.Value)&&(Dropdown8.SelectedText.Value)&&(Dropdown9.SelectedText.Value)&&(Dropdown10.SelectedText.Value)),"OK","Fail")

     

    Thanks for your help!

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 739 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 343 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard