There are common string functions are the useful in Tableau, many of which would be most useful during the data cleaning process.
What is a string?
A string is a data type that is a series of characters displayed with single or double quotation marks. In Tableau
Common String Functions
When creating a calculated field, a calculation pane can be found on the left and a search bar can be found in a gray pain on the right. Above the search bar is a dropdown menu with calculations categorized by function. When choosing "String," numerous string functions can be found in this category. Below are some of the most useful string functions.
LEFT / RIGHT
LEFT and RIGHT string functions both return the specified number of characters from a string. For the LEFT function, a specified number of characters will be returned from the start of the string, and for the RIGHT function, a specified number of characters will be returned from the end of the string. Below is a calculation using the LEFT function used with the Superstore data set as well as the result of both LEFT and RIGHT functions for the same data set
REPLACE
The REPLACE function searches a given string for a specified substring and replaces it with a specified replacement. Below is a calculation of the LEFT calculation used with the Superstore data set as well as the result of both LEFT and RIGHT functions for a sample of that data set.
CONTAINS
The CONTAINS function will return "True" if the given string contains the specified substring.
SPLIT
The SPLIT function splits apart a string and returns a substring (i.e., a part) from the string itself. The calculation includes 3 parts:
- String: this can be a single string 'Name' or a field [Customer Name].
- Delimiter: The character or space that separates the substrings (i.e., '-').
- Token Number: The part of the string to return, after the delimiter. Note a positive number instructs the function to work from left to right, while a negative number instructs the function to work from right to left.
FIND
The FIND function returns the position of a substring within entire string. The first character in the string is position 1. Below, the FIND function was used to identify the position of 'e' in each string.