top of page

Text Function

The Text function formats a number or a date/time value based on one of these types of arguments:

  • A predefined date/time format, which you specify by using the DateTimeFormat enumeration. For dates and times, this approach is preferred as it automatically adjusts to each user's language and region.

  • A custom format, which comprises a string of placeholders that define, for example, whether numbers show a decimal separator and dates show the full name of the month, the month as an abbreviation, or the month as a number. Power Apps supports a subset of the placeholders that Microsoft Excel does. In this string, the language placeholder specifies the language in which to interpret the other placeholders. If the custom format includes a period, for example, the language-format placeholder specifies whether the period is a decimal separator (ja-JP) or a thousands separator (es-ES).


The Text function can also convert any data type to a text representation using a default format. Use this to pass non-text values to text-based functions such as Len, Right, and IsMatch.


Predefined date/time formats

For these examples, date and time used is Tuesday, April 7, 2020 8:26:59.180 PM, in the time zone UTC-7 hours.



Number placeholders



If a number has more digits to the right of the decimal point than there are placeholders in the format, the number rounds to as many decimal places as there are placeholders. If there are more digits to the left of the decimal point than there are placeholders, the extra digits are displayed. If the format contains only number signs (#) to the left of the decimal point, numbers less than 1 start with a decimal point (for example, .47).


Date and time placeholders




Literal placeholders

You can include any of these characters in your format string. They will appear in the result of Text as is. Additional characters are reserved for future placeholders, so you shouldn't use them.



Global apps

The Text function is globally aware. For a wide array of languages, it knows how to properly write out dates, times, currencies, and numbers. To do its job, it needs two pieces of information:

  • The language of the custom format: For makers, how should a custom format be interpreted? The separator characters (. and ,) have different meanings in different languages. If you specify a custom format, you can include a language placeholder or take the default value, which reflects the language to which your device is set. Even easier, you can use one of the predefined date/time formats, which are language agnostic.

  • The language of the result: For users, in what language should the function result appear? Names of months and weekdays must be in the appropriate language for the user of the app, which you can specify by adding a third, optional argument to the Text function.

For both, you specify the language by using a language tag. To see the list of supported languages, type Text( 1234, "", ) in the formula bar or the Advanced tab of the right-hand pane, and then scroll through the list of locales suggested for the third argument.


Language placeholder

To specify the language of the custom format, use:


The language placeholder can appear anywhere in the custom format but only once.


If you specify a custom format without a language placeholder and the format is ambiguous from a global standpoint, the language tag for your current language is inserted automatically.

[$-en-US] is assumed if this placeholder isn't present when your app is run.


Note In a future version, the syntax of this placeholder may change to avoid confusion with a similar, but different, placeholder that Excel supports.


Result language tag

The result of Text includes translated strings for months, weekdays, and AM/PM designations, as well as the appropriate group and decimal separators.

By default, Text uses the language of the user running the app. The Language function returns the language tag for the current user. You can override this default value by supplying a language tag for the third argument to Text.


Syntax

Text( NumberOrDateTime, DateTimeFormatEnum [, ResultLanguageTag ] )

  • NumberOrDateTime - Required. The number or the date/time value to format.

  • DateTimeFormat - Required. A member of the DateTimeFormat enumeration.

  • ResultLanguageTag - Optional. The language tag to use for the result text. By default, the language of the current user is used.

Text( NumberOrDateTime, CustomFormat [, ResultLanguageTag ] )

  • Number - Required. The number or the date/time value to format.

  • CustomFormat - Required. One or more placeholders enclosed in double quotation marks.

  • ResultLanguageTag - Optional. The language tag to use for the result text. By default, the language of the current user is used.

Text( AnyValue )

  • AnyValue - Required. Value to convert to a text representation. A default format is used.

Examples

Unless otherwise specified, the user running these formulas is located in the United States and has selected English as their language. The Language function is returning "en-US".


Number




Date/Time

  • At 2:37:47 PM on Monday, November 23, 2015

  • United States Pacific Time Zone (UTC-8)



Global apps



Converting values to text




0 comments

Recent Posts

See All
bottom of page