Slice

Slice functions let you extract a specified substring from a text value. This is a quick way of removing unwanted flags at the ends of a text value or mapping strings to shorter values.

Excel

  • =~LEFT!~(‹string›«, length»)

  • =~RIGHT!~(‹string›«, length»)

=LEFT(A1) // "Female" -> "F"
=RIGHT(A2,5) // "MAIN24601" -> "24601"

NB. If «length» is left blank, it returns the 1st digit only.

Tableau

  • ~LEFT!~(‹string›, ‹length›)

  • ~RIGHT!~(‹string›, ‹length›)

LEFT([Gender], 1) // "Female" -> "F"
RIGHT([Cost Code], 5) // "MAIN24601" -> "24601"

Alteryx

  • ~LEFT!~(‹string›, ‹length›)

  • ~RIGHT!~(‹string›, ‹length›)

OrgVue

The general format of splice in OrgVue is: ‹dimension›.value.~slice!~(‹start_index›«, end_index»)

  • Left: ‹dimension›.value.~slice!~(0, ‹end_index›)

  • Right: ‹dimension›.value.~slice!~(-‹start_index›)

NB.:

  • The first character in a string has the index 0.

  • Negative numbers count from the end of the string.

  • If only 1 index is supplied, the default is to return all subsequent characters after that index, e.g.

tSQL

  • ~LEFT!~(‹field›, ‹length›)

  • ~RIGHT!~(‹field›, ‹length›)

  • ~MID!~(‹field›, ‹start›«, length»)

Python

The general splice format in Python is: ‹string›[«start_index»:«end_index»]

  • Left: ‹string›[:«end_index»]

  • Right: ‹string›[-«start_index»:]

NB.:

  • The first character in a string has the index 0.

  • Negative numbers count from the end of the string.

  • If only the «start_index» is supplied and no : is included, the expression behaves like [:1] has been provided, e.g.:

  • The above examples assume variables have been declared for gender, costCode, and orderNumber. For more information, go to General > Variables.

Last updated

Was this helpful?