TRIM_ARRAY

Applies to: ✅ Data 360 SQL ✅ Tableau Hyper API

Trims an array by removing the last n elements.

Syntax 

1TRIM_ARRAY(<array>, <count>)

Arguments 

Required 

  • <array>: The source array.
  • <count>: The number of elements to remove from the end.

Returns 

Returns an array with the specified number of elements removed from the end.

Considerations 

  • If the count exceeds the array length, returns an empty array.
  • The count must be a non-negative integer.

Examples 

Trim Last Elements 

Remove the last two elements from an array.

1SELECT TRIM_ARRAY(array[1, 2, 3, 4], 2) AS result;

Returns array[1, 2], removing the last 2 elements (3 and 4).

Related Documentation 

DID THIS ARTICLE SOLVE YOUR ISSUE?
Let us know so we can improve!