When building canvas apps in Power Apps, you’ll often receive numeric values as text. This commonly happens when data comes from SharePoint, Excel, Dataverse, user input controls, or external APIs. Since mathematical operations require numeric data types, you’ll need to convert text values into numbers before performing calculations.
Power Apps provides the Value() function for this purpose.
Why Convert Text to Numbers?
Consider the following scenarios:
- A user enters a value in a Text Input control.
- Numbers are imported from an Excel spreadsheet as text.
- A SharePoint text column stores numeric values.
- An API returns numbers as strings.
If you attempt calculations without converting the values, Power Apps may return errors or unexpected results.
For example, this formula won’t work correctly if TextInput1.Text is treated as text:
TextInput1.Text + 10
Instead, convert the text to a numeric value first.
Using the Value() Function
The syntax is straightforward:
Value( String )
Where:
- String is the text you want to convert into a number.
- The function returns a numeric value that can be used in calculations.
Example 1: Convert User Input
Suppose a user enters 250 into a text input control.
Value(TextInput1.Text)
The result is the number:
250
You can now use it in calculations.
Example 2: Perform Mathematical Operations
Value(TextInput1.Text) * 5
If the user enters 20, the result is:
100
Example 3: Add Two Text Inputs
If two text boxes contain numeric values:
Value(TextInput1.Text) + Value(TextInput2.Text)
If the values are 50 and 25, the result is:
75
Working with Different Regional Formats
Power Apps interprets numbers using the current user’s regional settings. For example:
Value("123.45")
works correctly for users whose locale uses a period (.) as the decimal separator.
You can also specify a language tag explicitly:
Value("123,45", "fr-FR")
This converts the value using French formatting, where the comma is the decimal separator.
This feature is especially useful for global applications used across multiple countries.
Currency and Percentage Values
The Value() function can also convert formatted numbers.
Currency example:
Value("$125.50")
Result:
125.50
Percentage example:
Value("25%")
Result:
0.25
Power Apps automatically converts percentages to their decimal equivalents.
Handling Invalid Values
If the supplied text isn’t a valid number, Power Apps returns an error.
Example:
Value("ABC")
To avoid runtime errors, combine Value() with IfError():
IfError(
Value(TextInput1.Text),
0
)
This returns 0 whenever the conversion fails.
Best Practices
When converting text to numbers in Power Apps:
- Use Value() before performing arithmetic operations.
- Validate user input to prevent conversion errors.
- Use IfError() to handle invalid values gracefully.
- Consider regional formatting when working with international users.
- Store numeric data in numeric columns whenever possible instead of text columns.
Conclusion
The Value() function is the standard way to convert text into numbers in Power Apps. Whether you’re processing user input, reading data from SharePoint or Excel, or consuming external APIs, converting text values ensures your formulas work correctly and calculations remain reliable.
For international applications, remember that Value() also supports locale-specific number formats, making it easier to build apps that work seamlessly for users around the world.
Reference:
Decimal, Float, and Value functions – Microsoft Learn
