All functions

Appian text()

Format numbers and dates as text: money, percentages, phone numbers, written-out dates and times. Extra decimals are cut off rather than rounded, which is the part that catches people.

Official Appian documentation

The shape

text(value, format) turns a number, date, time or datetime into text, shaped by a format string.

text(1234.5, "#,##0.00")   →   "1,234.50"

The result is text. Do every calculation first and format last; once a number has been through text() it is for display, not for arithmetic.

If the format contains 0, # or ?, it is a number format. Otherwise it is read as a date or time format.

Number formats

  • 0 — always a digit, padding with zeros: text(5, "000") is "005"
  • # — a digit only if there is one: text(5, "###") is "5"
  • . — the decimal point; , — thousands separators
  • $, spaces, brackets and other characters appear as written
  • % — multiplies by 100: text(0.25, "0%") is "25%"
  • + — shows the sign, plus or minus

Use 0 just before the decimal point, as in #,##0.00, so that zero prints as 0.00 rather than .00.

The trap: extra decimals are cut off, not rounded

This is the one that catches everybody. text(1.239, "0.00") is "1.23", not "1.24" — Appian drops the digits beyond the format, without rounding.

When you want rounding, say so first: text(round(1.239, 2), "0.00") is "1.24".

Different formats for positive, negative and zero

Semicolons split a format into sections: positive;negative;zero. The negative section shows the number without its minus sign, so it can supply its own — the accounting style:

text(-10.25, "$00.00;(00.00)")   →   "(10.25)"

With one section, a negative number simply gets a minus in front. A condition in brackets picks a section by value instead: [<=9999999]000-0000;(000) 000-0000 formats a 7-digit number one way and anything longer the other.

Digits fill a pattern from the right

Other characters stay where they are, and the digits flow into the 0 slots around them. That is how IDs are laid out:

text(5551234567, "(000) 000-0000")   →   "(555) 123-4567"

Date formats

  • mmmm February · mmm Feb · mm 02 · m 2
  • yyyy 2020 · yy 20
  • dd 27 · d 27 · ddd 27th · dddd Thursday
  • EEEE Thursday · EEE Thu

Note that ddd is the day with a suffix, not a short weekday name. For a short weekday, use EEE.

Time formats, and the double meaning of mm

  • h and hh — 12-hour clock; k and kk — 24-hour clock
  • ss — seconds
  • AM/PM, am/pm, A/P — in the case you write them

mm means month unless an hour appears somewhere to its left, in which case it means minutes. In mm/dd h:mm the first mm is the month and the second is the minutes.

Locale

Every output on this page is en_US. Appian formats by the user's locale, or the system's, so month names, separators and the currency sign can differ for other users.

Try it

Run each one and read what comes back before moving on.

Format a number with thousands separators and two decimals.

text(1234.5, "#,##0.00")

Compare 0 and # as placeholders.

{text(5, "000"), text(5, "###")}

1Format 1.239 to two decimals and read it closely.

text(1.239, "0.00")

2Round first, then format.

text(round(1.239, 2), "0.00")

Give negatives their own section, accounting style.

text(-10.25, "$00.00;(00.00)")

Lay digits out as a phone number.

text(5551234567, "(000) 000-0000")

1Write a date out in words.

text(date(2020, 2, 27), "mmmm d, yyyy")

2Compare ddd and dddd.

{text(date(2020, 5, 27), "ddd"), text(date(2020, 5, 27), "dddd")}

1Show a time on a 12-hour clock.

text(datetime(2020, 2, 27, 14, 5, 0), "h:mm AM/PM")

2Use mm twice in one format.

text(datetime(2020, 2, 27, 14, 5, 0), "mm/dd h:mm")

Independent evaluator — approximates the Appian expression language and may differ from a real Appian environment. Verify anything that matters. Terms

Exercises

0 of 7 cleared
  1. 1text(): format an amount as money
  2. 2text(): show a ratio as a percentage
  3. 3text(): round before you format
  4. 4text(): show negatives in brackets
  5. 5text(): format a phone number
  6. 6text(): write a date out in words
  7. 7text(): write a bank statement line
Start the first exercise