PowerApps 中的 Value 函数Value function in PowerApps

将文本字符串转换为数字。Converts a string of text to a number.

说明Description

Value 函数将包含数字字符的文本字符串转换为数字值。The Value function converts a string of text that contains number characters to a number value. 需要对用户以文本形式输入的数字执行计算时,请使用此函数。Use this function when you need to perform calculations on numbers that were entered as text by a user.

不同的语言对 ,. 的解释Different languages interpret , and . 各不相同。differently. 默认情况下,文本使用当前用户的语言进行解释。By default, the text is interpreted in the language of the current user. 可以通过语言标记指定要使用的语言,使用的语言标记与 Language 函数返回的语言标记相同。You can specify the language to use with a language tag, using the same language tags that are returned by the Language function.

字符串格式的说明:Notes on the format of the string:

  • 字符串可能以当前语言所对应的货币符号为前缀。The string may be prefixed with the currency symbol for the current language. 系统会忽略该货币符号,The currency symbol is ignored. 但不忽略其他语言的货币符号。Currency symbols for other languages are not ignored.
  • 字符串可能在末尾包含百分号 (%),表示这是百分比。The string may be include a percent sign (%) at the end, indicating that it is a percentage. 该数字在返回前将被除以 100。The number will be divided by 100 before being returned. 不能混用百分比和货币符号。Percentages and currency symbols cannot be mixed.
  • 字符串可能采用科学记数法,将 12 x 103 表示为“12e3”。The string may be in scientific notation, with 12 x 103 expressed as "12e3".

如果数字格式不正确,Value 将返回空白。If the number is not in a proper format, Value will return blank.

若要转换日期和时间值,请使用 DateValueTimeValueDateTimeValue 函数。To convert date and time values, use the DateValue, TimeValue, or DateTimeValue functions.

语法Syntax

Value( String [, LanguageTag ] )Value( String [, LanguageTag ] )

  • String - 必需。String - Required. 要转换为数字值的字符串。String to convert to a numeric value.
  • LanguageTag - 可选。LanguageTag - Optional. 一种语言标记,可以通过该标记来分析语言。The language tag in which to parse the string. 在未指定该标记的情况下,将使用当前用户的语言。If not specified, the language of the current user is used.

示例Examples

运行这些公式的用户位于美国,且已选择英语作为其语言。The user running these formulas is located in the United States and has selected English as their language. Language 函数返回的是“en-US”。The Language function is returning "en-US".

公式Formula 说明Description 结果Result
Value( "123.456" )Value( "123.456" ) 将使用默认语言“en-US”,该语言使用句点作为小数分隔符。The default language of "en-US" will be used, which uses a period as the decimal separator. 123.456123.456
Value( "123.456", "es-ES" )Value( "123.456", "es-ES" ) “es-ES”是在西班牙使用的西班牙语的语言标记。"es-ES" is the language tag for Spanish in Spain. 在西班牙,句点为千位分隔符。In Spain, a period is a thousands separator. 123456123456
Value( "123,456" )Value( "123,456" ) 将使用默认语言“en-US”,该语言使用逗号作为千位分隔符。The default language of "en-US" will be used, which uses a comma as a thousands separator. 123456123456
Value( "123,456", "es-ES" )Value( "123,456", "es-ES" ) “es-ES”是在西班牙使用的西班牙语的语言标记。"es-ES" is the language tag for Spanish in Spain. 在西班牙,逗号是小数分隔符。In Spain, a comma is the decimal separator. 123.456123.456
Value( "12.34%" )Value( "12.34%" ) 字符串末尾的百分号表示这是一个百分比。The percentage sign at the end of the string indicates that this is a percentage. 0.12340.1234
Value( "$ 12.34" )Value( "$ 12.34" ) 系统会忽略当前语言的货币符号。The currency symbol for the current language is ignored. 12.3412.34
Value( "24e3" )Value( "24e3" ) 12 x 103 所对应的科学记数法。Scientific notation for 12 x 103. 2400024000