Skip to main content

Notifications

Community site session details

Community site session details

Session Id : 44l9qvFnufgH/XStlewWtn
Power Apps - Building Power Apps
Answered

Disable button based off empty dropdown value

Like (1) ShareShare
ReportReport
Posted on 30 Sep 2018 01:20:59 by 64

I have an excel spreadsheet table that feeds my dropdown box values in Powerapps. I left an empty cell so that I can have an empty value as the first selection in my dropdown box.

 

I need to disable the submit button if the empty value is selected. I don't want the user to submit the form if the empty value is selected. I figured out how to disable the button for the "traffic" value but I do not know the name of that empty value to make my formula work. See screen shots.

 

Please help 🙂

 

If((Reasons_DD).Selected.Value = "Traffic",DisplayMode.Disabled,DisplayMode.Edit)

 

Capture_reasons.JPG

 

 

 

 

 

 

 

 

 

 

 

 

Capturedropdown.JPG

 

Categories:
  • wyotim Profile Picture
    2,545 on 24 Jan 2019 at 18:39:09
    Re: Disable button based off empty dropdown value

    @JD2301Awesome work! A couple suggestions about your code: it may be easier to read and change later if you use an Or statement instead of nesting If statements, especially because they have the same result. Something like:

     

    // Disable button if "Not Applicable" or "Please Select From List" is selected
    If(
     Or(Dropdown6.Selected.Value = "Not Applicable", Dropdown6.Selected.Value = "Please Select From List"), 
     DisplayMode.Disabled,
     DisplayMode.Edit
    )

    Also, you may test that your code works when selecting values other than "Not Applicable" and "Please Select From List" due to not explicitly having DisplayMode.Edit in there. It may not work properly. You may need to have something like (my addition to your code in bold):

     

    If(
    Dropdown6.Selected.Value = "Not Applicable",
    DisplayMode.Disabled,
    If(
    Dropdown6.Selected.Value = "Please Select From List",
    DisplayMode.Disabled,
    DisplayMode.Edit
    )
    )

    That stuff aside, I am happy you were able to get it working! 

  • JD2301 Profile Picture
    55 on 24 Jan 2019 at 18:27:27
    Re: Disable button based off empty dropdown value

    Hi Wyotim,

     

    That is perfect thank you. 
    I've set the button to be disabled if "Not Applicable" is selcted and I have changed the blank column to state "Please Select from List" and also managed to make the button disabled if this is chosen using the formula:
    If(Dropdown6.Selected.Value = "Not Applicable", DisplayMode.Disabled, If(Dropdown6.Selected.Value = "Please Select From List", DisplayMode.Disabled))

    Thanks for your help.

  • wyotim Profile Picture
    2,545 on 24 Jan 2019 at 15:35:25
    Re: Disable button based off empty dropdown value

    @JD2301Assuming your dropdown is named 'Assigned To dropdown' and that you want the button to be disabled when "N/A" is selected, you would use the following code in the DisplayMode property of your button:

     

    // Disable button if "N/A" is selected
    If(
     'Assigned To dropdown'.Selected.Value = "N/A", 
     DisplayMode.Disabled, 
     DisplayMode.Edit
    )


    I noticed that your dropdown was blank in the picture, so if you want to incorporate that into the mix, the following should work (again in the DisplayMode property of your button):

     

    // Disable button if dropdown is blank or "N/A" is selected
    If( Or(IsBlank('Assigned To dropdown'.Selected.Value), 'Assigned To dropdown'.Selected.Value = "N/A"), DisplayMode.Disabled, DisplayMode.Edit )

    If you instead want to make the button invisible, you would replace DisplayMode.Disabled with false and DisplayMode.Edit with true and put the formula in the Visible property of the button. You could also mix and match a bit, like if you want the button invisible when a blank value is in the dropdown but disabled when "N/A" is selected, but I digress. 

     

    Let me know if that works for you. Otherwise, let me know and I'll be happy to help out until it does!

     

    *edit for comment in second code snippet*

  • JD2301 Profile Picture
    55 on 24 Jan 2019 at 08:48:20
    Re: Disable button based off empty dropdown value

    Hi Wyotim,

     

    I have a similar problem to the original post, I've followed you're instructions but I cant seem to get mine to work!

    I have a radio button with "Pass" or "Fail". 
    If "Fail" gets selected, it brings up a Comments Box, a dropdown list & a "send email notification" button as shown below.
    The If statement I have used for these boxes to appear is if fail is selected is..
    If("fail" in Radio5_33.Selected.Value, true) ...which works fine.

    PAP3.pngHowever in the 'Assigned To dropdown', I have an option of "N/A".
    If N/A is selected, I want the 'Send Email Notification' button to either be hidden or be disabled so it is unable to be pressed. Do you know what formula I need to use to get this to work please?

    Thanks.

  • wyotim Profile Picture
    2,545 on 20 Oct 2018 at 18:30:11
    Re: Disable button based off empty dropdown value
    Awesome! I am happy to be able to help and very happy for your success!
  • ersula82 Profile Picture
    64 on 20 Oct 2018 at 14:08:09
    Re: Disable button based off empty dropdown value

    @wyotim that explanation was perfect and helped alot. So, with that understanding, I was able to add a 3rd condition on the Or Statement that I needed to add. I would not have been able to do so without your teaching so thank you! 

  • wyotim Profile Picture
    2,545 on 19 Oct 2018 at 02:12:10
    Re: Disable button based off empty dropdown value

    Okay, here we go on this explanation. This may be something you already know, so forgive me if this is too basic but I thought I would get into the And() and Or() functions. Without going too in depth or getting to basic, these functions compare two or more Boolean (true or false) statements and return a true or false based on the result.

     

    For And(), if all the compared statements are true, it returns true; otherwise, it returns false.

     

    For Or() if just one of the compared statements is true, it returns true; otherwise, it returns false.

     

    I can go more in-depth on these if you like, but that is the general idea.

     

    For the specific code, I will start with the And() section. The two statements it compares are:

     

    1) if the Other_Txt text is blank and

    2) if the Other_Txt label is visible.

     

    To return true, both of these statements must be true (i.e. the text is blank and the label is visible). Otherwise (i.e. if the text is not blank or the label is not visible), it will return false. Since the visibility of the Other_Txt input area is tied to the selection of "Other" in the Reasons_DD drop down, it is that selection that will trigger this statement. If it never becomes visible (i.e. "Other" is not selected), it will return false. 

     

    For the Or() section, we use:

     

    1) if the Reasons_DD drop down has nothing selected and

    2) the result of the previous And() section.

     

    For this to return true, just one of those needs to be true (i.e. Reasons_DD dropdown has nothing selected or both the Other_Txt text is empty and the Other_Txt label is visible). Otherwise, it will return false.

     

    Now, the result of the Or() statement is what then sets the true or false section of the If() statement. If it is true (meaning that the necessary areas are not selected/filled out), the item is disabled. Otherwise, it will be enabled.

     

    I am typing this on very little sleep so I hope it makes sense. Feel free to comment back if I need to better word things or if it was total gibberish.  

     

  • wyotim Profile Picture
    2,545 on 17 Oct 2018 at 14:44:29
    Re: Disable button based off empty dropdown value

    @ersula82 Glad it worked out! I will post an explanation of the nested statement, hopefully tonight but definitely by tomorrow.

     

    In my mind, it’s only a solution if it is repeatable and understood so I am happy to get into the details and make it as clear as I can.

  • ersula82 Profile Picture
    64 on 17 Oct 2018 at 13:24:25
    Re: Disable button based off empty dropdown value

    @wyotim this worked although I'm a little confused on the nesting statement but I guess I'll continue to learn as I go along. I was literally up for hours attempting every if statement variation I can think of so thank you for your speedy reply. You saved me time!

     

    Ersula

  • Verified answer
    wyotim Profile Picture
    2,545 on 17 Oct 2018 at 03:50:16
    Re: Disable button based off empty dropdown value

    @ersula82 Try this: 

     

    If(
    Or(
    IsBlank(Reasons_DD.Selected.Value),
    And(
    IsBlank(Other_Txtbox.Text),
    Other_Txtbox.Visible
    )
    ),
    DisplayMode.Disabled,
    DisplayMode.Edit
    )

    This is assuming that the Other_Txtbox is only visible when it is able to be used, and thus if it is visible it should not be blank either. Let me know if that works out for you.

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

Understanding Microsoft Agents - Introductory Session

Confused about how agents work across the Microsoft ecosystem? Register today!

Warren Belz – Community Spotlight

We are honored to recognize Warren Belz as our May 2025 Community…

Congratulations to the April Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 146,743 Most Valuable Professional

#2
RandyHayes Profile Picture

RandyHayes 76,287 Super User 2024 Season 1

#3
Pstork1 Profile Picture

Pstork1 66,089 Most Valuable Professional

Leaderboard
Loading started
Loading complete