TEXT
- TEXT(value, formatting=None)[source]
Converts a field or value to its text representation with optional formatting.
This function mimics the behavior of Excel’s TEXT function. It converts value to a string, optionally applying a formatting pattern. Both singular values and arrays are supported. If any argument is blank or in an error state, the formula evaluates to an error.
- Parameters:
value (
Operand) –The value or field to convert to text.
Supported types:
ANY
formatting (
Operand|str|None) –Optional. A string or field that specifies the text format to apply to value. If provided, must be a string or string array. Defaults to no formatting.
Supported types:
STRING
STRING_ARRAY
- Return type:
- Returns:
The text representation of value, optionally formatted. Returns an array if value or formatting is an array.
Supported types:
STRING
STRING_ARRAY
- Raises:
ValueError – If formatting is not STRING or STRING_ARRAY.
Examples
Basic usage with literals:
TEXT(123) # Returns "123"
Using formatting:
TEXT(0.75, "0.00%") # Returns "75.00%"
With field references:
TEXT(customer["balance"], "$0.00") # Returns formatted balance as text in dollar format
With array input:
TEXT([1, 2, 3], "00") # Returns ["01", "02", "03"]