 top of page
Search
• Bernard K

# Tableau string functions String functions are the type of calculations used to manipulate string data. For example, you might have a field that contains ‘Product Names’ with some of members of the field containing either a leading or a trailing space - you can use the string function TRIM () to remove any leading or trailing spaces.

E.g., TRIM ([Product Name])

### Other string functions include.

1. CONTAINS Function

This function returns TRUE if the given string contains the specified substring.

Syntax: CONTAINS (string, substring)

Example: CONTAINS (“Tableau”, “Table”) =TRUE

2. SPLIT Function

This function returns a substring from a string, using a delimiter character to divide the string into a sequence of tokens.

Syntax: SPLIT (string, delimiter, token number)

Example: SPLIT (‘Rigor-Data-Solutions’, ‘-‘, 2) = ‘Data’

SPLIT (‘Rigor-Data-Solutions’, ’-’, -1) = ‘Solutions’

3. ASCII Function

This function returns the ASCII code for the first character of the string.

Syntax: ASCII (string)

Example: ASCII (“Apple”) =65

4. ENDSWITH Function

This function returns TRUE if the given string ends with the specified substring. Trailing spaces are ignored.

Syntax: ENDSWITH (string)

Example: ENDSWITH (“Tableau”, “eu”) = FALSE

5. STARTSWITH Function

This function returns TRUE if the given string starts with the specified substring. Leading spaces are ignored.

Syntax: STARTSWITH (string)

Example: STARTSWITH (“Tableau”, “Ta”) = TRUE

6. FINDNTH Function

This function returns the position of the nth occurrence of substring within the specified string, where n is defined by occurrence argument.

Syntax: FINDNTH (string, substring, occurrence)

Example: FINDNTH (‘Adrian’, ‘a’, 2) = 5

7. LEFT Function

This function returns the left most number of characters in the string.

Syntax: LEFT (string, number)

Example: LEFT (‘Tableau’, 5) = ‘Table’

8. RIGHT Function

This function returns the right most number of characters in the string.

Syntax: RIGHT (string, number)

Example: RIGHT (‘Tableau Desktop’, 7) = ‘Desktop’

9. LEN Function

This function returns the length of the string.

Syntax: LEN (string)

Example: LEN (‘Salesforce’) = 10

10. LOWER Function

This function returns the string with all characters in lowercase.

Syntax: LOWER (string)

Example: LOWER (‘Tableau Desktop’) = ‘tableau desktop’

11. UPPER Function

This function returns the string with all characters in uppercase.

Syntax: UPPER (string)

Example: UPPER (‘Tableau Public’) = ‘TABLEAU PUBLIC’

12. REPLACE Function

This function searches a string for a substring and replaces it with a replacement. If the substring is not found, the default string is returned.

Syntax: REPLACE (string, substring, replacement)

Example: REPLACE (‘Tableau Desktop’, ‘Desktop’, ‘Online’) = ‘Tableau Online’

13. LTRIM Function

This function returns the string with any leading spaces removed.

Syntax: LTRIM (string)

Example: LTRIM (“ Tableau “) = “Tableau ”

14. RTRIM Function

This function returns the string with any trailing spaces removed.

Syntax: RTRIM (string)

Example: RTRIM (“ Tableau “) = “ Tableau”

15. TRIM Function

This function returns the string with any leading or trailing spaces removed.

Syntax: TRIM (string)

Example: TRIM (“ Tableau “) = “Tableau”

More string functions can be accessed on the calculated field editor – by selecting ‘String’ on the side menu.  