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 / Multiple IF Statements...
Power Apps
Answered

Multiple IF Statements (or Switch) to control a Save Buttons Visibility

(0) ShareShare
ReportReport
Posted on by 301

Hi,

 

I have a canvas app with several dropdowns, and textboxes and a save icon. This app also has one important Radio Button with a simple Yes or No options.


If my users select "Yes" on the radio, the users have to fill out an extra dropdown and a text box

But if they select "No" they do not have to fill out the extra dropdown and a text box.

My question is in regards to the Save Icon, i would only like the Save Icon only to be Visible if none of the dropdowns and text boxes are blank with a condition of If the user selects No on the radio button the extra dropdown and text box may then be blank.

 

Im assuming its a multiple If Statment or a Switch statment.

Could someone help myself write it?

 

 

Categories:
  • StalinPonnusamy Profile Picture
    Super User 2024 Season 1 on at

    Hi @ShaneITAutomate 

     

    Set Save button Display mode property to

     

    Sample

    If(
     ToggleDataCardValue.Value,
     If(
     !IsBlank(StatusDropdown.Selected.Value) && !IsBlank(TextBox1.Text),
     DisplayMode.Edit,
     DisplayMode.Disabled
     ),
     DisplayMode.Edit
    )

     

     

  • StalinPonnusamy Profile Picture
    Super User 2024 Season 1 on at

    Hi @ShaneITAutomate 

     

    We can add multiple conditions like my example below

    If(
     ToggleDataCardValue.Value,
     If(
     !IsBlank(PriortityDropdown.Selected.Value) && !IsBlank(StatusDropdown.Selected.Value) && !IsBlank(PNCard.Text),
     DisplayMode.Edit,
     DisplayMode.Disabled
     ),
     DisplayMode.Edit
    )

     

     

  • ShaneITAutomate Profile Picture
    301 on at

    In my mind using your examples i would have something such as below in my save icons visible function, however it doesnt work

     

     

    If(
     ToggleDataCardValue.Selected.Value = "No" && !IsBlank(Required_NO_OR_YESDropdown1.Selected.Value) && !IsBlank(RequiredIF_NO_OR_YESDropdown2.Selected.Value) && !IsBlank(Required_NO_OR_YESText1.Text),
     If(
     !IsBlank(ExtraIfYESStatusDropdown.Selected.Value) && !IsBlank(ExtraIfYESTextBox1.Text),
     true,
     false
     ),
     true
    )

     

     

    To make things clearer if my example code above makes no sense as it doesn't work for what i need. In my app besides the radio button that is also required for my save icons visible function is i have say two dropdowns that are required to not be blank if the dropdown is yes or no and one textinput that is required if yes or no, i will call these

     

    RequiredIF_NO_OR_YESDropdown1

    RequiredIF_NO_OR_YESDropdown2

    Required_NO_OR_YESText1

     

    And one extra dropdown if just yes and one extra text input if just yes. ill call them as follows

     

    ExtraIfYESStatusDropdown1
    ExtraIfYESTextBox1

     

    So if my radio button equals "Yes" all 3 dropdowns and 2 text inputs must all not be blank for my save icon to be visible,

     

    i.e

    RequiredIF_NO_OR_YESDropdown1

    RequiredIF_NO_OR_YESDropdown2

    Required_NO_OR_YESText1
    ExtraIfYESStatusDropdown1
    ExtraIfYESTextBox1


    but if my radio button equals no then only

    RequiredIF_NO_OR_YESDropdown1

    RequiredIF_NO_OR_YESDropdown2

    Required_NO_OR_YESText1

     

    need to be not blank for my save icon to be visible.

     

    I hope this makes sense

     

  • KvB1 Profile Picture
    1,596 on at

    In your formula, the first If checks if all the conditions are met for if the user selected 'No', and if that passes, will check if the conditions are met for if the user selected 'Yes'.

     

    The simplest but somewhat ugly thing to do would be to just throw them all into one If statement sepperated by an 'or'

     

     

    If(
    	(
    	Len(RequiredIF_NO_OR_YESDropdown1.Selected.Value)>1 &&
    	Len(RequiredIF_NO_OR_YESDropdown2.Selected.Value)>1 &&
    	Len(Required_NO_OR_YESText1.Text)>1 &&
    	Len(ExtraIfYESStatusDropdown1.Selected.Value)>1 &&
    	Len(ExtraIfYESTextBox1.Text)>1 &&
    	ToggleDataCardValue.Selected.Value = "Yes"
    	) Or
    	(
    	Len(RequiredIF_NO_OR_YESDropdown1.Selected.Value>1 &&
    	Len(RequiredIF_NO_OR_YESDropdown2.Selected.Value>1 &&
    	Len(Required_NO_OR_YESText1.Text>1 &&
    	ToggleDataCardValue.Selected.Value = "No"
    	),
    	true,
    	false
    )
    	

     

    The prettier way would be to use a nested If, where the first If checks whether the fields that are mandatory in both scenarios have been filled in, and if so, to check the value of the toggle to see whether the additional fields need to be filled as well.

  • ShaneITAutomate Profile Picture
    301 on at

    Im so confused, can you show me a nested if statment example using my example??

  • Verified answer
    KvB1 Profile Picture
    1,596 on at

    It's very valuable to understand these kinds of things, for being able to make small changes and maintenance.

     

    If(
     Len(Required_NO_OR_YESDropdown1.Selected.Value)<1 Or Len(RequiredIF_NO_OR_YESDropdown2.Selected.Value)<1 Or Len(Required_NO_OR_YESText1.Text)<1,
     false,
     If(
    	ToggleDataCardValue.Selected.Value = "Yes",
     Len(ExtraIfYESStatusDropdown.Selected.Value)>1 And Len(ExtraIfYESTextBox1.Text)>1,
     true
     )
    )

     

     

     

     

    Lets go through it step by step:

     

    If(
     Len(Required_NO_OR_YESDropdown1.Selected.Value)<1 Or Len(RequiredIF_NO_OR_YESDropdown2.Selected.Value)<1 Or Len(Required_NO_OR_YESText1.Text)<1,

     

    This will check if any of the fields ar empty that are mandatory for both a Yes or No toggle on your radio. You want the control to be invisible if any of these fields are empty, in any situation, so if this test returns true (any or all of the fields are empty), we want the next argument to be false (control is invisible).

     

    After the false, we will have the second argument of the If function, which is what the if function will do if the first argument returns false. In this situation, ALL the mandatory fields for both situations have been filled, and we want to check if the toggle is a Yes or not.

     

    If(
     Len(Required_NO_OR_YESDropdown1.Selected.Value)<1 Or Len(RequiredIF_NO_OR_YESDropdown2.Selected.Value)<1 Or Len(Required_NO_OR_YESText1.Text)<1,
     false,
     If(
    	ToggleDataCardValue.Selected.Value = "Yes",

     

     

     

    If the toggle is set to "Yes", the visibility property of the control relies on whether the extra text box and dropdown have been filled. So if the inner If function finds that the Toggle is set to "Yes", it will return the second argument of the If function.

     

    If(
     Len(Required_NO_OR_YESDropdown1.Selected.Value)<1 Or Len(RequiredIF_NO_OR_YESDropdown2.Selected.Value)<1 Or Len(Required_NO_OR_YESText1.Text)<1,
     false,
     If(
    	ToggleDataCardValue.Selected.Value = "Yes",
     Len(ExtraIfYESStatusDropdown.Selected.Value)>1 And Len(ExtraIfYESTextBox1.Text)>1,

     

     

     

    The second argument of the If function will return true if both the Dropdown and Text have been filled, and false if either of them havent. Since the visibility property of a control is also a false or true, leaving it like this is perfectly fine.

     

    When the inner If function does NOT find that the Toggle is set to "Yes", it will jump to the third argument of its function. In this scenario, we will assume that that means the toggle is set to "No". Since we already validated the mandatory fields for both scenarios have been filled (else the outer If function wouldn't have reached the inner If function) we can just return true.

     

    If(
     Len(Required_NO_OR_YESDropdown1.Selected.Value)<1 Or Len(RequiredIF_NO_OR_YESDropdown2.Selected.Value)<1 Or Len(Required_NO_OR_YESText1.Text)<1,
     false,
     If(
    	ToggleDataCardValue.Selected.Value = "Yes",
     Len(ExtraIfYESStatusDropdown.Selected.Value)>1 And Len(ExtraIfYESTextBox1.Text)>1,
     true
     )
    )

     

  • ShaneITAutomate Profile Picture
    301 on at

    For anyone reading this,

     

    It took me awhile but this is the solution

     

    If(
     RadioWorAlo.Selected.Value = "No" && !IsBlank(RequiredIF_NO_OR_YESDropdown1.Selected.Value) && !IsBlank(RequiredIF_NO_OR_YESDropdown2.Selected.Value) && !IsBlank(RequiredNO_OR_YESText1.Text) 
     true,
     IsBlank(ExtraIfYESDropdown1.Selected) || IsBlank(ExtraIFYESTextBOX1),false,true)

     

    Fark me that was frustrating

  • ShaneITAutomate Profile Picture
    301 on at

    Thanks i found a solution around the same time you posted yours, i just accepted yours for you time. Thank you for your explanation and time i genuinely appreciate it. 

  • KvB1 Profile Picture
    1,596 on at

    No worries ^^ you sure the formula you posted works correctly? Because it seems that if the Toggle is set to "Yes", the control will be visible even if the 3 fields mandatory for both situations are not filled in, it will only check if the additional 2 are filled in.

  • ShaneITAutomate Profile Picture
    301 on at

    Yeah you where 100% right, i had to fix that lol Thanks. I think i have the multiple IF statments figured out internally now. (till next time if i dont forget)

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 432 Super User 2026 Season 2

#2
Mohsin Ali Profile Picture

Mohsin Ali 347

#3
WarrenBelz Profile Picture

WarrenBelz 254 Most Valuable Professional

Last 30 days Overall leaderboard