You want to know, how to convert a text to number in PowerApps? Use the Value Function like this:
// Example PowerApps: Convert Text To Number Value("21.89") => 21.89 (number)
If this is all you need to know, have a nice day!
The rest of the article describes, how to convert text to number for different international number formats, which will texts work and which won’t and we take a deeper look at the PowerApps Value Function.
PowerApps Value Function
The PowerApps Value Function converts a string to a number. Based on the given language tag, local number formats are taking into account during conversion.
Value( String [, LanguageTag ] )
- String (mandatory): String that needs to be converted to a number.
- LanguageTag (optional): The language tag, that is used to convert the string to a number. If none is set, the current user’s language is used.
- number, converted from the string. Conversion is influenced by the given language.
- blank, if the string can not be converted.
PowerApps Value Function Examples
Value("21.89") => 21.89 (number) Value("21.89","en-US") => 21.89 (number) Value("$ 9.45") => 9.45 Value("abc") => blank
Locale Number Format
A dot and a comma have different meanings in different countries.
For example in the US the dot is used as a decimal separator and the comma as thousands separator.
In Germany it is the opposite, the comma is used as a decimal separator and the dot as thousands separator.
That’s why number 12.345 has different meaning in the US and in Germany. This is why you can pass a language tag to the value function.
Value("12.345";"en-US") => twelve and .. Value("12.345";"de-DE") => twelve thousand three hundred ...
Within in your Power App the user’s language is used to convert a text to a number by default. You can overwrite the language tag by providing one as shown above.
What kind of strings can be converted to a number
Strings that have any character beside the number within the text, will not be converted to a number.
The result for these strings will be blank.
Only the following cases will be converted to a number.
Strings with currency symbols
Currency symbols get ignored, if they are:
- prefixed to the number (postfix does not work)
- the currency for the used language
We need some examples here:
Value("$12.34";"en-US") => 12.34 Value("€12.34";"en-US") => blank (€ does not match en-US) Value("12.34€";"de-DE") => blank (currency is not prefixed)
Strings with percentage signs
String with a percentage sign will be implicitly divided by 100.
Value("100%") => 1 Value("% 100") => 1 Value("25,4%") => 0,254
Strings in scientific notation
The string may be in scientific notation, with 12 x 103 expressed as “12e3”.
Value("12e3") => 12000