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 / complex IF/DefaultResu...
Power Apps
Answered

complex IF/DefaultResult statement

(0) ShareShare
ReportReport
Posted on by 16

I hope this isn't a silly question.  I've looked at " If and Switch functions - Power Platform | Microsoft Learn"

I'm checking to make sure each box on my canvas has been filled in before patching. 
Am I doing this right? check each condition, then group the DefaultResult inside parenthesis? I know the syntax is not precisely correct, but I am hoping it is clear enough. I am focusing on how to do the Default result, when the multiple set statements need to be separated with a comma, but they are not meant to be additional conditions.

If(
(TextInput1_1.Text ="Text input"), (Set(TextCanvasvar1,"No Input 1")),
(TextInput1_2.Text="Text input"), (Set(TextCanvasvar2,"No Input 2")),
(TextInput1_3.Text="Text input"), (Set(TextCanvasvar3,"No Input 3")),
//default
(Set(TextCanvasvar1,"default1"),
Set(TextCanvasvar2,"default2"),
Set(TextCanvasvar3,"default3")
) //end default
); // end if

I've tested it. power apps definitely does not like my default steps.
any thoughts?

Categories:
I have the same question (0)
  • Verified answer
    VishalJhaveri Profile Picture
    1,167 Moderator on at
    If(IsBlank(textbox1), Navigate(errorScreen),
    	If(IsBlank(textbox2), Navigate(errorScreen),
     	If(IsBlank(textbox n), Navigate(errorScreen), Set(var1,textBox1.Text); Set(var2,textbox2.Text);Set(varn,textBoxn.Text)))
  • djs-tas Profile Picture
    16 on at

    I might be tired. my eyes are getting blurry. I think I may have tried this and got funny results. You may be right. I am thinking out loud.
    The syntax (as I understood) is 
    If (

    condition1, true executable statement,

    condition2, true executable statement,

    default executable statement
    )
    most programming languages use cascading if statements, but in Power Apps, a cascading if would be the 'default case' of the 'parent' if statement (in effect, the false case of the parent)
    so the first Set (variable, value); terminates the last (innermost) if statement with a semicolon. The second Set (,);  terminates the middle If with a semicolon, and the last Set(,) does not need a semicolon because the closing parenthesis terminates all the other if statements

  • Verified answer
    timl Profile Picture
    36,393 Super User 2025 Season 2 on at

    Hi @djs-tas 

    If I understand you correctly, the answer is to separate default conditions with semi-colons rather than parenthesis. It would look more like this:

    If(
     (TextInput1_1.Text ="Text input"), (Set(TextCanvasvar1,"No Input 1")),
     (TextInput1_2.Text="Text input"), (Set(TextCanvasvar2,"No Input 2")),
     (TextInput1_3.Text="Text input"), (Set(TextCanvasvar3,"No Input 3")),
     //default
     Set(TextCanvasvar1,"default1");
     Set(TextCanvasvar2,"default2");
     Set(TextCanvasvar3,"default3")
     //end default
    ); // end if
  • djs-tas Profile Picture
    16 on at

    sometimes, Power Apps does not honor step-by-step execution, so if I were to code

    If (condition1, statement1) ;
    If (condition2, statement2) ;

    If (condition3, Navigate(another screen));
    There is no guarantee that If1 and If2 will be processed. It is not reliable or predictable, as far as I can tell, which makes using the cascading If statements concerning to me.

     

  • djs-tas Profile Picture
    16 on at

    You are correct. This works. 
    why does the last default case not have a semicolon?

     

  • djs-tas Profile Picture
    16 on at

    another possible solution (although, not very graceful) that I came up with is to use another screen, where the 'OnVisible' property sets all the values, and ends with a call to the Back() function.
    while not ideal, are there problems with this solution? I am learning (trying to learn). This way would not be very readable. Might be slow?

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 721 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 320 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard