Understanding NULL, Blank, and Empty in Power Apps: A Comprehensive Guide” because

I noticed significant differences in how NULL and Blank values are handled in Power Apps compared to C#. Here are my findings.

スポンサーリンク

Overview

In Power Apps, “blank” represents either “no value” or an “unknown value”.

For instance, the Selected property of a combobox returns blank when nothing is selected. Furthermore, in Power Apps, boolean values can not only be true or false but can also hold a blank value.

Think of Excel – you can clear the contents of cells, right?

Additionally, Empty specifically refers to a table that contains no records.

Note:
We are currently in a transition period regarding blank value handling.

Due to error handling limitations, blank values can only be stored in local collections.

The handling of blank values may change in future updates.

Details

When you want to use a **”blank”** value, use the **Blank() function**.

Assigning a Blank() is similar to assigning NULL in other programming languages.

While you might be tempted to use the IsBlank() function to check for blank values, this requires careful consideration.

IsBlank() is quite sensitive and responds to both “blank” values and “empty strings”.

If you want to check for blank values only,

if(valueToCheck = Blank())

Create an if statement using the Blank() function like this.

The Coalesce function examines its arguments in order and returns the first value that is neither “blank” nor an “empty string”.

Coalesce is strict about its arguments – they must all be of the same type. Don’t mix numbers and strings in the same function call.

IsEmpty is equivalent to (CountRows() == 0).
Remember that Blank and Empty are different concepts, so use them appropriately.

Examples

  • IsBlank(“Rainy”) => false
  • IsBlank(Blank()) => true
  • Coalesce(Blank(),1) => 1
  • Coalesce(“”, 2) => 2
  • Coalesce(Blank(),””,Blank(),””,3,4) => 3
  • Coalesce(“”) => Blank()
  • IsBlank(Blank()) => true
  • IsBlank(“”) => true
  • IsBlank(“Hello”) => false
  • IsBlank(someCollection) => false
  • IsBlank(Mid(“Hello”), 17, 2) => false

* This is because there is no 17th character from the middle of “Hello”

  • IsBlank(if(false,false)) => true

* This occurs because the If function specification states that it returns blank when no conditions are true, no matches are found, and no default result is specified.

  • IsEmpty([1,2,3]) => false
  • IsEmpty([]) => true
  • IsEmpty(Filter([1,2,3],Value>5)) => true

* This is because there are no values greater than 5 in the array

Summary

In Power Apps, Blank is similar to Null.

However, the IsBlank function also responds to empty strings (“”).

The IsEmpty function is used with tables and doesn’t respond to empty strings.

IsEmpty(“”) returns false.

Related Articles

コメント

Copied title and URL