cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
sammybridge
Helper IV
Helper IV

Power Apps Errors when Converting Text to Value

Hello,

 

Ever since the newest release of Power Apps, I have started getting errors that I didn't have before. The bulk of my errors are saying "We cannot convert the value to a number because the value is an empty string" and this is what I have shown below. As you can see though, the string has the number 5 in it and is not blank. This is causing issues throughout the app as the error is showing hundreds of times as this field drives a lot.

 

Has anyone seen this issue?

 

sammybridge_0-1618241787513.png

 

1 ACCEPTED SOLUTION

Accepted Solutions
ModernMusic
Regular Visitor

I just got this issue when I opened my app this morning, I worked in it all day yesterday without any problems but this morning am seeing the same thing.  I've actually seen this once before dealing with formatting dates. 

 

I believe the problem is that PowerApps is now assessing possible runtime errors of certain variable types BEFORE you might actually encounter them.  For example, now when you launch your app in PowerApps Studio, Text values for which your code block reads Value(DataCardValue78.Text) as shown in your screenshot, are being flagged as possible runtime errors immediately.  This is because when the app launches, DataCardValue78 is blank...EVEN if as a user moves through your app there's no way to submit DataCardValue78 as a blank value, if it's blank when the app launches it is being flagged as a possible future runtime error.  

 

The solution I've found, which has worked for this specific issue and also my old dates issue, is to modify your code in all error situations and replace "Value(DataCardValue78.Text)" with "IfError(Value(DataCardValue78.Text), Blank())"  This way, even if it's impossible for your user to have a blank value in DataCardValue78 when actually using the app, from a coding perspective the possibility of a blank value is handled with the IfError function. 

 

Looking at your specific code, my further recommendation may be to set DataCardValue78.Text to a variable first, and then use the variable in place of your direct call to the data card value in your code posted above.  Something like Set(VariableNameX, IfError(Value(DataCardValue78.Text), Blank()))

View solution in original post

7 REPLIES 7
eka24
Super User
Super User

Value you tried removing the Value from the formulas?

------------

If you like this post, give a Thumbs up. Where it solved your request, Mark it as a Solution to enable other users find it.

Yeah it won’t let me remove that as I’m comparing with a value rather than a string. I need the Value in there 

ModernMusic
Regular Visitor

I just got this issue when I opened my app this morning, I worked in it all day yesterday without any problems but this morning am seeing the same thing.  I've actually seen this once before dealing with formatting dates. 

 

I believe the problem is that PowerApps is now assessing possible runtime errors of certain variable types BEFORE you might actually encounter them.  For example, now when you launch your app in PowerApps Studio, Text values for which your code block reads Value(DataCardValue78.Text) as shown in your screenshot, are being flagged as possible runtime errors immediately.  This is because when the app launches, DataCardValue78 is blank...EVEN if as a user moves through your app there's no way to submit DataCardValue78 as a blank value, if it's blank when the app launches it is being flagged as a possible future runtime error.  

 

The solution I've found, which has worked for this specific issue and also my old dates issue, is to modify your code in all error situations and replace "Value(DataCardValue78.Text)" with "IfError(Value(DataCardValue78.Text), Blank())"  This way, even if it's impossible for your user to have a blank value in DataCardValue78 when actually using the app, from a coding perspective the possibility of a blank value is handled with the IfError function. 

 

Looking at your specific code, my further recommendation may be to set DataCardValue78.Text to a variable first, and then use the variable in place of your direct call to the data card value in your code posted above.  Something like Set(VariableNameX, IfError(Value(DataCardValue78.Text), Blank()))

View solution in original post

Hi @ModernMusic 

 

I think that has fixed the issue using IfError. Annoyingly I had to go and do it for all of my Update coding in my datacards which I know Power Apps gave me and I didn't put like that to begin with (some of them were still locked which is how I know). 

 

Regarding the variable I implemented this and I think that has helped too. I was actually working with a variable for that field in other places in my app but as this was the same form didn't decide to go for it for that field. 

 

Thanks for your help!

TeeroyLyon
Helper I
Helper I

Hi All,

 

I just started getting this error this morning for all of my Value() conversions.  And I thought "what did I do yesterday to cause this to suddenly start happening?".   So, I was getting a nasty error message at the top of my form for a variable I was trying to set in my App.Onstart.  In searching for a way to totally turn off the error messages that appear at the top of the form, I found the "Turn on/off Formula-level error management" in the Settings->Advanced Settings->Experimental features section of my app.  As soon as I turn this on, the nasty error message goes away (great!).  However, now the environment is generating these "We cannot convert the value to a number..." errors  "pre-emptively" for all controls I have the Value() conversion on.  Just an FYI on what might be causing this suddenly for you.

 

Cheers,

Troy

james_hathaway
Helper II
Helper II

Although that workaround will work, I would say that it's not quite correct - It is ensuring that the final value is valid (and not an error), but it will NOT stop the Value() formula from throwing the possible runtime error.

 

In My Opinion - this should NOT be a runtime error anyway, and is clearly a BUG.

In no other programming language does value("") evaluate to ERROR - it should evaluate to 0 (zero).

 

Interestingly, Value(Blank()) DOES evaluate to zero - so the correct workaround to catch these possible runtime errors would be:

Value(If(isBlank(DataCardValue78.Text),Blank(),DataCardValue78.Text)).

 

This in itself shows the stupid and inconsistent nature of the PowerFX Language :- 

Value("") = ERROR

isBlank("") = true

Value(Blank())=0

So, although "" != Blank(), isBlank("") is True... ????!!!??!?!?!?

 

Please Microsoft - FIX THIS!!

Value("") should evaluate to zero!

Thanks @james_hathaway, this worked for me!

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

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