cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
ericonline
Community Champion
Community Champion

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
v-xida-msft
Community Support
Community Support

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

11 REPLIES 11
Mike8
Memorable Member
Memorable Member

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.

rebeccas
Community Champion
Community Champion

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. 

rebeccas
Community Champion
Community Champion

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

v-xida-msft
Community Support
Community Support

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.

Thanks for the explanation @v-xida-msft

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

 

Anonymous
Not applicable

The accepted solution here isn't quite complete. A ComboBox initializes such that IsBlank(ComboBox.SelectedItems) is True, but IsEmpty(ComboBox.SelectedItems) is False. Then if a value is selected both become False, as expected, however, if the values are deselected, i.e. removed from the selection using the little X buttons, IsBlank evaluates to False and IsEmpty evaluates to True.

 

In other words, you have to check for both, because IsBlank works before the ComboBox has been touched, and IsEmpty works after it has.

 

I never use the "ComboBox.SelectedItems".

 

If it is is people picker I use IsBlank(ComboBox1.Selected.DisplayName) and if it is a combo box for choice field or something like that I use IsBlank(ComboBox1.Selected.Value). It will recognize when you add in a selection and then clear it out. 

 

The only time I can think of that I use IsEmpty is for Attachments. 

I figured it out...

 

JimBingham_0-1642543342555.png

 

Thanks for the explanation. 

How do you check if Number text input field is empty as "" or isblank not working. 

Helpful resources

Announcements
Microsoft 365 Conference – December 6-8, 2022

Microsoft 365 Conference – December 6-8, 2022

Join us in Las Vegas to experience community, incredible learning opportunities, and connections that will help grow skills, know-how, and more.

Difinity Conference 2022

Difinity Conference 2022

Register today for two amazing days of learning, featuring intensive learning sessions across multiple tracks, led by engaging and dynamic experts.

European SharePoint Conference

European SharePoint Conference

The European SharePoint Conference returns live and in-person November 28-December 1 with 4 Microsoft Keynotes, 9 Tutorials, and 120 Sessions.

Power Apps Ideas

Changes to Ideas Coming

We are excited to announce a new way to share your ideas for Power Apps!

Top Solution Authors
Top Kudoed Authors
Users online (1,987)