Skip to main content

String Functions (Locked)

Row-level string functions. Signatures cite help.tableau.com. All available in Desktop 2020.1+ unless noted.

FunctionSignatureReturnNotes
CONTAINSCONTAINS(string, substring)BooleanCase-sensitive.
STARTSWITHSTARTSWITH(string, prefix)BooleanCase-sensitive.
ENDSWITHENDSWITH(string, suffix)BooleanCase-sensitive.
FINDFIND(string, substring, [start])IntegerReturns position (1-based) or 0 if not found.
FINDNTHFINDNTH(string, substring, occurrence)IntegerPosition of Nth occurrence.

Extract and Transform​

FunctionSignatureReturnNotes
LEFTLEFT(string, N)StringFirst N characters.
RIGHTRIGHT(string, N)StringLast N characters.
MIDMID(string, start, [length])StringSubstring.
LENLEN(string)IntegerCharacter length.
LOWERLOWER(string)StringLowercase.
UPPERUPPER(string)StringUppercase.
PROPERPROPER(string)StringTitle case.
REPLACEREPLACE(string, substring, replacement)StringFirst occurrence only? Check docs; behavior is all-occurrences in most versions.
TRIMTRIM(string)StringStrip leading and trailing whitespace.
LTRIMLTRIM(string)StringStrip leading whitespace.
RTRIMRTRIM(string)StringStrip trailing whitespace.
SPACESPACE(N)StringReturns N space characters.
CHARCHAR(codepoint)StringCharacter for Unicode codepoint.
ASCIIASCII(string)IntegerASCII code of first character.

Split​

FunctionSignatureReturnNotes
SPLITSPLIT(string, delimiter, token_number)StringReturns the Nth token, 1-indexed. Negative index counts from end.

Regex (2013.1+, all supported versions)​

FunctionSignatureReturnNotes
REGEXP_MATCHREGEXP_MATCH(string, pattern)BooleanFull pattern match.
REGEXP_EXTRACTREGEXP_EXTRACT(string, pattern)StringFirst capture group.
REGEXP_EXTRACT_NTHREGEXP_EXTRACT_NTH(string, pattern, N)StringNth capture group.
REGEXP_REPLACEREGEXP_REPLACE(string, pattern, replacement)StringGlobal replace.

Aggregate-context Rewrites (see aggregate.md for full aggregate string functions)​

MAX(string) and MIN(string) in aggregate contexts return lexicographic min/max, not string length.

Common Anti-Patterns​

  • Bare LEFT([Field], 3) = 'ABC' when STARTSWITH([Field], 'ABC') reads more clearly.
  • CONTAINS(LOWER([Field]), 'abc') when regex would perform better on large datasets (R-PERF-01).
  • SPLIT with 0 or unbounded token numbers; token_number must be a specific integer.
  • REGEXP_MATCH inside aggregations where a pre-aggregated equivalent exists (R-PERF-01).

Version Notes​

All string functions available Desktop 2020.1+. Regex functions available Desktop 2013.1+.