LEFT

LEFT(input_string, length)[source]

Returns a substring consisting of the leftmost characters from a string.

This function mimics the behavior of Excel’s LEFT function. It extracts a substring from the start of input_string, up to the number of characters specified by length. Both singular values and arrays are supported. If any argument is blank or in an error state, the formula evaluates to an error.

Parameters:
  • input_string (Operand | str) –

    The string from which characters will be extracted. Can be a literal string, a field, formula, calculation, or parameter.

    Supported types:

    • STRING

    • STRING_ARRAY

  • length (Operand | int) –

    The number of characters to extract from the left of input_string. If negative, the formula evaluates to an error.

    Supported types:

    • INTEGER

    • INTEGER_ARRAY

Return type:

Formula

Returns:

The substring consisting of the leftmost characters of input_string up to index. If either input is an array, an array of substrings is returned.

Supported types:

  • STRING

  • STRING_ARRAY

Raises:
  • ValueError – if input_string is not of type STRING or STRING_ARRAY.

  • ValueError – if index is not of type INTEGER or INTEGER_ARRAY.

Examples

Basic usage:

LEFT("Hello World", 5)
# Returns "Hello"

Using a Field or Formula:

LEFT(customer["name"], 3)
# Returns first three characters of the customer's name

With array input:

LEFT(["Apple", "Banana", "Cherry"], 2)
# Returns ["Ap", "Ba", "Ch"]