cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Super User
Super User

IsBlank(), IsEmpty(), or = " " ?

I've got an app with a bunch of custom code baked into the Submit button DisplayMode property. The button will not become editable until the user completes all the questions/enters values for each. Text boxes are easy to validate in this way, but Dropdowns and Comboboxes are not.

  • IsBlank(Dropdown.Selected.Value) does not work for Dropdowns
    • It doesn't throw an error
  • IsEmpty(Combobox.Selected) does not work for Dropdowns NOR Comboboxes
    • It doesn't throw an error either
  • If(Dropdown.Selected.Value = " ",x,y) seems to work for Dropdowns IF the array has a " " in it

What is the best method for validating dropdowns and comboboxes have values? Attached is a test app showing what I mean.

Thank you!

1 ACCEPTED SOLUTION

Accepted Solutions
Community Support Team
Community Support Team

Re: IsBlank(), IsEmpty(), or = " " ?

Hi @ericonline,

Based on your issue that you provided, I think you have some misunderstanding with IsBlank() function and IsEmpty() function.

The IsBlank() function is used to check if a value is Blank. The IsEmpty() function is used to check if a table contains any records, in other words, the IsEmpty() function is used to detect if there is no records within a Table.

More details about IsBlank() function and IsEmpty() function, please check the following article:

IsBlank() function and IsEmpty() function

In addition, the "" (empty string) is not equal to Blank. The following formula would always return false:

"" = Blank()                 /* <-- Please type this formula within a Label control to test it.*/

The "" (empty string) is a string text value, but there is no character within it.

On your side, I assume that there is no "" value within the array data related to the Dropdown and ComboBox control, if you want to check if a Dropdown value or a ComboBox value is Blank, please take a try with the following workaround:

Set the DisplayMode property of the Button1 control to following:

If(
   IsBlank(Dropdown1.Selected.Value),     /* <-- Dropdown1 represents the Dropdown control */
   DisplayMode.Disabled,
   DisplayMode.Edit
)

Set the DisplayMode property of the Button2 control to following:

If(
IsEmpty(ComboBox1.SelectedItems), /* <-- ComboBox1 represents the ComboBox control */
DisplayMode.Disabled,
DisplayMode.Edit
)

Note: By default, if there is no "" value within the array data related to the Dropdown control, the Dropdown control would be populated with available values, in other words, the first item within the array data would be selected by default in the Dropdown control, so you could not use the IsBlank() function to detect if the selected option is blank.

If there is a "" value within the array data related to the Dropdown and ComboBox control, please take a try with the following workaround:

Set the DisplayMode property of the Button1 control to following:

If(
   IsBlank(Dropdown1.Selected.Value),     /* <-- Dropdown1 represents the Dropdown control */
   DisplayMode.Disabled,
   DisplayMode.Edit
)

Set the DisplayMode property of the Button2 control to following:

If(
IsEmpty(ComboBox1.SelectedItems) || IsBlank(ComboBox1.Selected.item), /* <-- ComboBox1 represents the ComboBox control */
DisplayMode.Disabled,
DisplayMode.Edit
)

 

Best regards,

Kris

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

5 REPLIES 5
Highlighted
Mike8
Level 10

Re: IsBlank(), IsEmpty(), or = " " ?

Hello ericonline,

I don't know what is the best method.
The first thing I thought about the combobox is IsEmpty(Combobox.SelectedItems) but I think it has a bug. 
The first time you insert a combobox, IsEmpty(Combobox.SelectedItems) returns false, even if it's empty. If you select a value and then delete the value from the SelectedItems, by pressing the small X icon, then it returns true. I don't like this.
So I tried IsBlank(First(ComboBox1.SelectedItems).ColumnName) and I think it works fine. You can test it.

Super User
Super User

Re: IsBlank(), IsEmpty(), or = " " ?

Put a hidden label that pulls those fields and refer to it. 

 

I have to do that a lot on Combo boxes because if not...if they put it in, the button shows and when they back up and remove it the button doesn't go away.

 

If you have a ton of fields there are a few other options but just a few this works pretty well. 

Super User
Super User

Re: IsBlank(), IsEmpty(), or = " " ?

On the Combobox instead of IsEmpty you use !IsBlank(datacardvalue)

Community Support Team
Community Support Team

Re: IsBlank(), IsEmpty(), or = " " ?

Hi @ericonline,

Based on your issue that you provided, I think you have some misunderstanding with IsBlank() function and IsEmpty() function.

The IsBlank() function is used to check if a value is Blank. The IsEmpty() function is used to check if a table contains any records, in other words, the IsEmpty() function is used to detect if there is no records within a Table.

More details about IsBlank() function and IsEmpty() function, please check the following article:

IsBlank() function and IsEmpty() function

In addition, the "" (empty string) is not equal to Blank. The following formula would always return false:

"" = Blank()                 /* <-- Please type this formula within a Label control to test it.*/

The "" (empty string) is a string text value, but there is no character within it.

On your side, I assume that there is no "" value within the array data related to the Dropdown and ComboBox control, if you want to check if a Dropdown value or a ComboBox value is Blank, please take a try with the following workaround:

Set the DisplayMode property of the Button1 control to following:

If(
   IsBlank(Dropdown1.Selected.Value),     /* <-- Dropdown1 represents the Dropdown control */
   DisplayMode.Disabled,
   DisplayMode.Edit
)

Set the DisplayMode property of the Button2 control to following:

If(
IsEmpty(ComboBox1.SelectedItems), /* <-- ComboBox1 represents the ComboBox control */
DisplayMode.Disabled,
DisplayMode.Edit
)

Note: By default, if there is no "" value within the array data related to the Dropdown control, the Dropdown control would be populated with available values, in other words, the first item within the array data would be selected by default in the Dropdown control, so you could not use the IsBlank() function to detect if the selected option is blank.

If there is a "" value within the array data related to the Dropdown and ComboBox control, please take a try with the following workaround:

Set the DisplayMode property of the Button1 control to following:

If(
   IsBlank(Dropdown1.Selected.Value),     /* <-- Dropdown1 represents the Dropdown control */
   DisplayMode.Disabled,
   DisplayMode.Edit
)

Set the DisplayMode property of the Button2 control to following:

If(
IsEmpty(ComboBox1.SelectedItems) || IsBlank(ComboBox1.Selected.item), /* <-- ComboBox1 represents the ComboBox control */
DisplayMode.Disabled,
DisplayMode.Edit
)

 

Best regards,

Kris

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

Super User
Super User

Re: IsBlank(), IsEmpty(), or = " " ?

Thanks for the explanation @v-xida-msft

In the attached sampleApp, I duplicated your code and added some things like Lookup() for blanks, etc.

 

Helpful resources

Announcements
thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Power Platform World Tour

Find out where you can attend!

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

Top Kudoed Authors
Users Online
Currently online: 185 members 5,234 guests
Recent signins:
Please welcome our newest community members: