How to evaluate empty TextBox in PowerApps?

4.6k views Asked by At

I have two column in my Excel Table (DataSource) and I am trying to evaluate both columns. Column 1 contains data and Column 2 is empty as shown below. The default FormMode is Edit, which contains 2 textboxes titled as "Column 1" and "Column 2", with 1 button to see the collection (See Below Code). Before using If condition I wanted to check whether I can see my record for row 1. The dafault property for Column1 is set to Gallery2.Selected.Column1 and the default property for Column 2 is set to " ". I used below code to see whether the collection will return my record,unfortunately instead of returning my record I saw Empty table with my column names i.e Column1 and Column2 under View -> Collections. Not sure what is wrong with below code. The code should return expected output in View> Collections.

Any help is appreciated!

Data Source

enter image description here

Code:

ClearCollect(Test,LookUp(Table1,Column1=DataCardValue6.Text && Column2= " ")

Expected Output

enter image description here

Updated Code:

ClearCollect(Test,LookUp(Table1,Column1=DataCardValue6.Text && Column2= IsBlank(Trim(Column2Name))))
1

There are 1 answers

7
kshkarin On

Use IsBlank and Trim to check for any empty or whitespace strings.

IsBlank(Trim(Column2))

Trim will remove any whitespace and IsBlank will return a true/false if the string is empty or not after the trim.

IsBlank

Trim

UPDATE: Check only for IsBlank where Column2 is evaluated, the way you wrote it it's checking if Column2 = bool which will have a type mismatch since it's checking a string vs a bool, change to this:

ClearCollect(Test,LookUp(Table1,Column1=DataCardValue6.Text && IsBlank(Trim(Column2))))