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

Set(varTest, Blank() ) = false ?

Man! I've been hung up on this for like 20 mins!

  • OnVisible of screen: Set(varTest, Blank())
  • Label Text Property: varTest
    • Label shows "false"
  • In other parts of the app i'm actually setting varTest to true and false!!

I've been baffled by how varTest was being set to "false"... IT WASN"T!  In Label Controls, it appears, a Blank variable is a false variable!

Have to set the Label Text Property to...

 

If(
IsBlank(varTest), "I'm Blank", varTest = true, "true", varTest = false, "false" )

 

...to see the Blank() state.

1 ACCEPTED SOLUTION

Accepted Solutions
Power Apps Staff CarlosFigueira
Power Apps Staff

Re: Set(varTest, Blank() ) = false ?

I have attached an app that reproduces the behavior that @ericonline originally reported (to open it, save it locally, then go to https://create.powerapps.com, select Open-> Browse, and find the file that you saved).

If you set a variable to Blank(), its value is indeed blank - it's not false. If you use a label to display that value, it will first convert it to text, then it will show it. Since the variable is defined as a boolean by usage in other parts of the app, then PowerApps (which is "strongly typed", as it will enforce the types of its variable assignments), will use default conversion from boolean to text, which returns "true" if the value of the variable is true, and "false" otherwise.

If you want to have a different text representation of that variable, then you cannot rely on the default conversion from boolean to text - for example, using the expression below:

If(IsBlank(varTest), "<blank>", varTest)

Hope this helps!

View solution in original post

10 REPLIES 10
Community Support Team
Community Support Team

Re: Set(varTest, Blank() ) = false ?

Hi @ericonline,

 

I cannot reproduce your issue. 

  • OnVisible of screen: Set(varTest, Blank())
  • Label Text Property: varTest

Label shows blank as expected.

 

 

Have you make sure that OnVisible of screen is the only formula that you have to set and update varTest variable? 

 

You can check this and take a screenshot as below:

Capture.JPG

 

Regards,

Mona

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

Re: Set(varTest, Blank() ) = false ?

Hi @ericonline 

Like Mona, I also can't recreate this condition. This probably isn't what you expect to hear, but I hope it helps in some way to further diagnose the problem.

Super User
Super User

Re: Set(varTest, Blank() ) = false ?

@ericonline 

I was able to reproduce the situation you are seeing.  The key is...you are assigning a boolean value at some point in your App.

If you assign just the Blank to the variable - the variable type will be ObjNull

As soon as you put any other formula in your App that sets that variable to true or false, the variable becomes a Boolean.

(you can confirm all of this by viewing the variables in your App).

 

The oddity to me is that you can assign a Blank() to a Boolean variable.  If you (once the variable "becomes" a boolean) try to assign anything but true or false (and apparently Blank()) then you will get an error.  SO...I suppose Booleans are really tri-state variables.

 

 

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.
Super User
Super User

Re: Set(varTest, Blank() ) = false ?

Hi guys,

I'm baffled by this!

@RandyHayes - I agree with what you say because it's consistent with my experience of how variables work. I'm pretty sure I tried what you did in my initial test. However, I still can't recreate this behaviour!

I've set varTest in various places. It's a Boolean, according to the Variables page.

 

image.png

In the OnVisible of the screen, I set varTest to true. Button 3 sets it to false, Button 2 sets it to Blank(). The screen works as I'd expect. When it first appears, the label says true. When I click Button 3, it says false. When I click Button 2, the label says "I'm Blank". I took the screenshot above after I clicked Button 2 - the page reports the value of varTest as "No Value".

 

image.png

 

varTest is a boolean and in the formula where I assign it to Blank(), I don't see any errors. @RandyHayes - I'm guessing you're seeing an error that says you're assigning an incompatible type to varTest?

I've closed and re-opened my app. I've re-published it, and I've tried it in both Chrome and Firefox (incase there are any differences in the JavaScript engine). In all of these cases, I can't reproduce the behaviour.

What could be causing this difference in behaviour?

Power Apps Staff CarlosFigueira
Power Apps Staff

Re: Set(varTest, Blank() ) = false ?

I have attached an app that reproduces the behavior that @ericonline originally reported (to open it, save it locally, then go to https://create.powerapps.com, select Open-> Browse, and find the file that you saved).

If you set a variable to Blank(), its value is indeed blank - it's not false. If you use a label to display that value, it will first convert it to text, then it will show it. Since the variable is defined as a boolean by usage in other parts of the app, then PowerApps (which is "strongly typed", as it will enforce the types of its variable assignments), will use default conversion from boolean to text, which returns "true" if the value of the variable is true, and "false" otherwise.

If you want to have a different text representation of that variable, then you cannot rely on the default conversion from boolean to text - for example, using the expression below:

If(IsBlank(varTest), "<blank>", varTest)

Hope this helps!

View solution in original post

Super User
Super User

Re: Set(varTest, Blank() ) = false ?

@timl 

Actually, your test is pretty much consistent with mine and the results are the same.

But, looking at @ericonline 's original post, I believe the issue was that Blank() showed as false.  Which seemed consistent with it being a boolean (as later defined by assigning a boolean).

So...not sure if there is just a misunderstanding. 

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.
Super User
Super User

Re: Set(varTest, Blank() ) = false ?

@CarlosFigueira 

Ah the speed of pressing the post button...I was just replying as well.

 

Thanks for the sample app.  It's pretty much what I was seeing as well and had assumed on Boolean types.  It is good to know though, that a variable is strongly typed and that, in the case of a boolean, anything other than true, is false.

 

Although, I would say there is then an inconsistency from the fact that you can assign a Blank() value to a strongly typed Boolean.  HOWEVER, given the nature of the datasources that PowerApps consumes (and the very likely potential that a boolean field is blank/null) that it would be needed (in fact, for all types).

 

 

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.
Super User
Super User

Re: Set(varTest, Blank() ) = false ?

Hi @RandyHayes , @CarlosFigueira , @timl . Thanks for peeking at this. Its nice to know I'm not crazy. I DO remember Carlos schooling me a while ago on SQL BIT data types and the fact that they also can have 3 values (true, false, NULL). 

This is a similar situation. Not sure if its a bug, but it definitely had me running circles for awhile.

  • My goal was to set a variable to Blank() because it affects the Default Property of a Toggle (cannot be true or false because it will toggle the toggle one way or the other).
  • Then once the user moves the toggle, the variable is set to the value of the toggle.
  • Seemed logical. Thought I was being a cool programmer and all... efficient and stuff by using a single variable like this... 🙂

One key here: I assign the Blank() value to the variable FIRST (OnVisible of the screen), then depending on what the user does with the Toggle Control, set it to true/false based on user action. 

Hm...

Super User
Super User

Re: Set(varTest, Blank() ) = false ?

@ericonline 

So, the one bit of advice I can share based on some of your statements in that post...stop thinking like a programmer!!  You're not programming, your making formulas!  It's a challenge for a programmer to get over that hump, but once you do, everything becomes so much clearer.

Of course, everyone's app will have a different challenge to it and the principles of development are helpful in some cases, but I find that they slow me down trying to "do it the way I would develop it".

 

Instead of trying to assign variables and putting variable assignments on actions, have your other controls or formulas "look" at the properties of each other.  

I look back at my first apps - they were LOADED with actions, variables, collections, tons of troubleshooting labels to tell me what all the variables were and just a mess of spaghetti code (or spaghetti formulas in this case).

Today, some of my most complex apps have only a couple of variables (and mostly for screen stuff) and rarely a collection of any great value. 

 

OF Course (did I mention this?) everyone's app will have a different challenge.  I'm not implying that my apps are the same as everyone else's, nor that they should be - just stating that once I got over that "programmer" hurdle, it all became incredibly easy.

 

Just sharing a bit of advice in case it helps you going forward.  And now I have $0.02 less 😉

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.

Helpful resources

Announcements
thirdimage

Power Apps Super User Class of 2020

Check it out!

thirdimage

New Badges

Check it out!

thirdimage

Power Apps 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

SecondImage

Difinity Conference

The largest Power BI, Power Platform, and Data conference in New Zealand

Top Solution Authors
Top Kudoed Authors
Users online (5,036)