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 / Nested If Statement pr...
Power Apps
Unanswered

Nested If Statement problem

(0) ShareShare
ReportReport
Posted on by

Hi, hope someone can help me with my problem.

 

I have an Icon that has the following code in its 'DisplayMode' property;

 

If(IsBlank(TextInput_1) ||
IsBlank(TextInput_2) ||
IsBlank(TextInput_3) ||
IsBlank(ComboBox_1) ||

IsBlank(ComboBox_2) ||
IsBlank(ComboBox_3), DisplayMode.Disabled, DisplayMode.Edit)

 

This works as when all the text inputs and comboboxes are filled the icon is then visible. However, I would also like to introduce the following statement into to the above code;

 

If(IsBlank(ComboBox_4) || IsBlank(TextInput_4),DisplayMode.Disabled, DisplayMode.Edit)

 

So basically the above statement is assessed on its own and then the result is assessed along with the other statements. Example below (which doesn't work);

 

If(IsBlank(TextInput_1) ||
IsBlank(TextInput_2)||
IsBlank(TextInput_3)
IsBlank(ComboBox_1) ||
IsBlank(ComboBox_2) ||
IsBlank(ComboBox_3) ||
If(IsBlank(ComboBox_4) || IsBlank(TextInput_4)),
DisplayMode.Disabled, DisplayMode.Edit)

 

I've tried various other ways but just can't get it to work. Any help appreciated.

 

Regards

 

Categories:
I have the same question (0)
  • iAm_ManCat Profile Picture
    18,228 Most Valuable Professional on at

    Heya, so first of all you should be referencing the property of each control that you want to check for Blanks, not the control itself directly - often it does understand and get the right property but I have had many times in the past where it checks a different property of the control rather than the Text or etc - this is especially true for combo boxes where the item in the combo box could have many fields and the IsBlank could check a different property.

     

    Then regarding your question about the nested if, you need to have the inner if as part of the 'then' which creates a new layer of 'if':

    If(
     IsBlank(TextInput_1) ||
     IsBlank(TextInput_2) ||
     IsBlank(TextInput_3) ||
     IsBlank(ComboBox_1) ||
     IsBlank(ComboBox_2) ||
     IsBlank(ComboBox_3),
     //Then
     If(
     IsBlank(ComboBox_4) || IsBlank(TextInput_4),
     //Then - Nested inner
     DisplayMode.Disabled,
     DisplayMode.Edit
     ),
     //Else condition for when none of the above are true
     DisplayMode.Edit
    )

     

    Cheers,

    Sancho

  • Marty3012 Profile Picture
    on at

    HI @iAm_ManCat 

    Thanks for your quick response. I used your solution and there are no more errors. However I noticed a couple of things;

    • When I fill out the fields and fill the Combobox_4 and TextInput_4 fields last, all works ok and the icon is made editable
    • If I fill out Combobox_4 and TexInput_4 first, then the icon becomes editable and doesn't take into account that the rest of the fields are blank.

    Should also say that once all fields have a value and I then change the Combobox_4 and TextInput_4, the icon still stays enabled. Thanks

  • Verified answer
    iAm_ManCat Profile Picture
    18,228 Most Valuable Professional on at

    Ah, so there may have been a misunderstanding based on your original code, I'll change it based on what you've described and put more comments in the code - if you can just let me know if that's correct and if not then how you want the logic to work:

     

    If(
     IsBlank(TextInput_1) ||
     IsBlank(TextInput_2) ||
     IsBlank(TextInput_3) ||
     IsBlank(ComboBox_1) ||
     IsBlank(ComboBox_2) ||
     IsBlank(ComboBox_3),
     // If any of the above are blank, make it disabled
     DisplayMode.Disabled,
    
     // Otherwise, if none are blank, check this condition
     If(
     IsBlank(ComboBox_4) || IsBlank(TextInput_4),
     // If either of the above two are blank then make it disabled
     DisplayMode.Disabled,
     // If none of the fields are blank, then make it enabled
     DisplayMode.Edit
     )
    )

     

    Cheers,

    Sancho

  • Marty3012 Profile Picture
    on at

    Thanks, that works!

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

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 333 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard