Skip to content
Home » Text function Power Apps

Text function Power Apps

Power Apps Text function is used to convert any value and formats a number or date/time value to a string of text.

Syntax:

Text(Value, Format, ResultLanguageTag)
  • Value- Required. The number or the date/time value to format.
  • Format- Required. A member of the DateTimeFormat enumeration or Custom format.
  • ResultLanguageTag– Optional. ResultLanguageTag to use for the result text. By default, the language of the current user is used.

Let’s explore the Text function, as you can see here we have a gallery control which contains orders data.




Now, we will use predefined and custom formats to format the Order Date.

Format a dates/time using Text function

There are some predefined date formats available in Power Apps which you can use to convert dates into desired format.

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.

Lets convert the Order date into LongDate using predefined date format.

Select the Order date item in gallery and set it’s Text property to code as shown below.

Here, first argument of text function is the date/time value that you want to format and second argument is to format the date/time value into LongDate.

Text(
ThisItem.'Order Date',
DateTimeFormat.LongDate
)

Now, you can see the date is converted into long date format.

To accessing all the predefined date/time formats, just write Text function and provide first argument value then press comma (,) and you will see it suggests you all the available data formats.

Similarly, you can explore others dates/time formats.

Let’s take a look at them, assume that input order date is 11/11/2014 5:30 AM , which is in mm/dd/yyyy format.

LongDateTime :

Text('Order Date', DateTimeFormat.LongDateTime)

Output: Tuesday, November 11, 2014 5:30:00 AM

LongDateTime24:

Text('Order Date', DateTimeFormat.LongDateTime24)

Output: Tuesday, November 11, 2014 5:30:00

LongTime:

Text('Order Date', DateTimeFormat.LongTime)

Output: 5:30:00 AM

LongTime24:

Text('Order Date', DateTimeFormat.LongTime24)

Output: 5:30:00

ShortDate:

Text('Order Date', DateTimeFormat.ShortDate)

Output: 11/11/2014

ShortDateTime:

Text('Order Date', DateTimeFormat.ShortDateTime)

Output: 11/11/2014 5:30 AM

ShortDateTime24:

Text('Order Date', DateTimeFormat.ShortDateTime24)

Output: 11/11/2014 5:30

ShortTime:

Text('Order Date', DateTimeFormat.ShortTime)

Output: 5:30 AM

ShortTime24:

Text('Order Date', DateTimeFormat.ShortTime24)

Output: 5:30

UTC:

Text('Order Date', DateTimeFormat.UTC)

Output: 2014-11-11T00:00:00.000Z

Format a date/time using custom format

You can customize the date/time value using appropriate custom format.

Below are the list of available formats that you can use to customize your date/time values.

d: displays the day as a number without a leading zero.

dd: displays the day as a number with a leading zero when appropriate.

ddd: displays the short name of day name such as Mon, Tue..

ddd: displays the full name of day such as Monday, Tuesday..

m: displays the month as a number without a leading zero.

mm: displays the month as a number with a leading zero when appropriate.

mmm: displays the short month name such as Jan, Feb..

mmmm: displays the full name of month such as January, February..

yy: displays the year as a two-digit number.

yyyy: displays the year as four-digit number.

s: displays the second as a number without a leading zero.

ss: displays the second as a number with a leading zero when appropriate.

f: displays the fractions of seconds.

AM/PM, a/p: displays the hour based on a 12-hour clock. Text returns “AM” or “a” for times from midnight until noon and “PM” or “p” for times from noon until midnight.




Format the date/time value into “dd/mm/yyyy” format

Text(ThisItem.'Order Date',"dd/mm/yyyy")

You can see, now dates is converted into “dd/mm/yyyy” format.

Format the date/time value into “dd/mmm/yyyy” format

Text(ThisItem.'Order Date',"dd/mmm/yyyy")

You can see, now dates is converted into “dd/mmm/yyyy”  format.

Format the date/time value into “mmm, dd yyyy” format

Text(ThisItem.'Order Date',"mmm, dd yyyy")

You can see, now dates is converted into “mmm, dd yyyy” format.

Similarly, you can explore other custom formats to convert date/time values into desired format.

Format a numbers using Text function

Format the number as percentage

To format the number as percentage, we need to use custom format “0.00%”.

Text(89,"0.00%")

Format the number with two decimal place

To format the number with two decimal place, we need to use custom format “#.##”.

Text( 5657.727,"#.##")

Following custom format pads the decimal portion of the number with zeros for one decimal place if there is no decimal portion and includes a second decimal place if supplied.

Pads the decimal portion of the number with zeros for one decimal place.

Text( 5657, "#.0#" )

Now, if you add two or more digits after decimal then it will show the number with two decimal only.

Format the number with comma as thousands separator

To format the number with comma as thousand separator, we need to use custom format “#,###”.

Format the number as currency

To format the number as currency, we need to use custom format “$ #,###.00”.




This format will show the currency value with two decimal place and comma as thousand separator.

Text( 1503.54, "$ #,###.00" )

If you want to explore more about Text function in detail, you can refer to post.

Also Read..

Create a variables in Power Apps

Collection in Power Apps

ClearCollect function in Power Apps

Highlight selected item in gallery

 

Loading

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.