Power Apps Value Function – How to use

Microsoft provides a list of functions to make Power Apps applications more flexible and responsive. One of the key functions within Power Apps is the “Value” function. The Value function is used to convert a text string into a number or date/time format.

In this tutorial, I will explore all the information about the PowerApps Value function, including its definition and properties.

Also, we will discuss how to convert PowerApps text to number, and how to convert PowerApps date to number.

Power Apps Value Function

Power Apps Value Function converts a string of text to a number value. It can be used to calculate numbers.

You can specify the value with a language tag that is returned by the Language function. The string of text is interpreted in the language of the current user. Different languages interpret “,” and “.” differently.

Below are some points that you need to remember while working with the Power Apps Value Function:

  • If the string is in scientific notation with “15*10^2“, the value will be expressed as “15e2“.
  • If the string contains a percentage symbol (%) at the end, it specifies as a percentage. The specific number will be divided by 100 before it is returned.
  • You need to keep in mind that Percentages and Currency symbols can not be mixed.
  • If a string contains a Currency symbol ($) for the current language, it will ignore it. However, the currency symbol is not ignored for other languages.
  • If the number is not in a proper format, then a blank value will return.
  • Similarly, you can convert the date and time values using the DateValue, TimeValue, or DateTimeValue functions.
See also  How to Create CSV File in SharePoint Using Power Apps?

Power Apps Value Function Syntax

The syntax of PowerApps Value Function is:

Value( String [, LanguageTag ] )

Where,

  • String = This is Required. Provide a text or string to convert it to a numeric value.
  • LanguageTag = This is optional. It helps to parse the string. It will use the current user’s language if you do not specify a language. The Language function always returns “en-US. “

Power Apps Value Function Examples

Follow the table below that represents some Value function examples with different formulas and their results.

FormulaDescriptionResult
Value( “789,123” )“es-ES” is the language tag for Spanish in Spain. In Spain, a period is a thousand separators789123
Value( “789.123” )Here, the default language of “en-US” will be used, which uses a period as the decimal separator789.123
Value( “789.123”, “es-ES” )“es-ES” is the language tag for Spanish in Spain. In Spain, a period is a thousand separators789123
Value( “54e3” )This specifies the scientific notation for 54*10^354000
Value( “78.19%” )Here the value represents a percentage symbol at the end of the string, so it is a percentage0.7819
Value( “$ 78.19” )Here, the currency symbol is ignored for the current language78.19
Value( “789,123”, “es-ES” )“es-ES” is the language tag for Spanish in Spain. In Spain, a Comma specifies with a Decimal separator789.123

Power Apps Convert Text to Number

Here, we will see how to convert text input to a numerical value or number in Power Apps with a simple scenario:

Scenario:

I have created a SharePoint Online list named “Products Details.” this list contains the below fields.

Column NameData Type
Product NameIt is a default single line of text
Purchase DateDate and time
PriceNumber
convert text to number powerapps

In Power Apps, there are two text input controls: a date picker and a button control. Whenever the user adds a new record and clicks on the button control, the new record will be saved with the product’s price, including the currency format.

See also  The JSON function cannot serialize tables / objects with a nested property called '_ownerid_value' of type 'Polymorphic' Power Apps

Have a look at the below screenshot for the output.

powerapps value function

To Work around this, follow the below steps. Such as:

1. On the Power Apps Screen -> Insert two text input controls [txt_ProductName and txt_Price], a date picker control [dte_Purchasedate], and a button control [btn_Submit].

value function powerapps

2. Now, select the button control and set its OnSelect property to the code below.

OnSelect = Patch(
    'Product Details',
    Defaults('Product Details'),
    {
        Title:txt_ProductName.Text ,
        'Purchase Date': dte_PurchaseDate.SelectedDate,
        Price: Value(txt_Price.Text)
    }
)

Where,

  • Product Details = SharePoint Online list
  • Price: Value(txt_Price.Text) = We can use the Value() function to convert the text into a number
powerapps convert text to number

3. Once your app is ready, Save, Publish, and Preview it. When a user submits a new record, the new record will be saved with the product’s price, including the currency format, as shown below.

This is how we can convert the Power Apps text to a number.

power apps convert text to number

Power Apps Convert Date to Text

Next, I will show you how to convert the Power Apps convert date to text with a simple example.

Example:

I have created a Power Apps collection [colProducts] manually by using two text inputs control, a date picker control, and a button control.

The record is stored in the Power Apps collection whenever the user adds a new record and clicks on the button. Now, I would like to display this collection record on the data table and change the date format to a text value.

Have a look at the below screenshot for the output:

convert date to text in powerapps

To achieve it, follow the below steps. Such as:

1. On the Power Apps screen -> Select the Button control and set its OnSelect property to the code below.

OnSelect = Collect(
    colProducts,
    {
        ProductName: txt_ProductName.Text,
        PurchaseDate: dte_PurchaseDate.SelectedDate,
        Price: txt_Price.Text
    }
)

Where,

  • colProducts = Power Apps collection name
value in powerapps

2. Then, insert a Data table control and set its Items property to the code below.

Items = colProducts
power apps value function

3. To display the Power Apps data table fields, click the Edit fields option and choose your respective fields, as shown below.

convert text to number in powerapps

4. Now, select the Date field [PurchaseDate] and set its Text property with the below-mentioned code.

Text = Text(ThisItem.PurchaseDate,"mmm dd,yyyy")

Where,

  • ThisItem.PurchaseDate = Power Apps date field
  • “mmm dd,yyyy”= This is the format that you want to convert a Date to text
power apps text to number

5. Similarly, If you want to display the Date text format within your Date picker control only, you can set its Format property as:

Format = "mmm dd,yyyy"
value function in powerapps

6. Save, Publish, and Preview the app. The data table converts the date format to a text value whenever the user adds a new collection record, as in the screenshot below.

See also  How to Create CSV File in SharePoint Using Power Apps?

This way, you can convert the Power Apps date format into the text value.

powerapps convert string to number

The Power Apps Value() function is a fundamental and very important function within Power Apps for converting text inputs into numeric or date/time values.

I trust you find this article useful; in this Power Apps tutorial, we learned in detail information about the Power Apps value function, including:

  • Power Apps convert text to number
  • Power Apps convert date to text

Also, you may like:

>