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
![](https://www.thedataschool.co.uk/content/images/2023/09/String.png)
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.
![](https://www.thedataschool.co.uk/content/images/2023/09/String2.png)
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
![](https://www.thedataschool.co.uk/content/images/2023/09/LEFT-1.png)
![](https://www.thedataschool.co.uk/content/images/2023/09/LEFT--RIGHT-1.png)
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.
![](https://www.thedataschool.co.uk/content/images/2023/09/image-316.png)
![](https://www.thedataschool.co.uk/content/images/2023/09/image-315.png)
CONTAINS
The CONTAINS function will return "True" if the given string contains the specified substring.
![](https://www.thedataschool.co.uk/content/images/2023/09/CONTAINS.png)
![](https://www.thedataschool.co.uk/content/images/2023/09/CONTAINS1.png)
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.
![](https://www.thedataschool.co.uk/content/images/2023/10/6D82718A-2168-4AB0-9F29-CAABA0345578_1_201_a-1.jpeg)
![](https://www.thedataschool.co.uk/content/images/2023/10/43C858E3-F642-471D-BE1B-2442C61662B7_4_5005_c.jpeg)
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.
![](https://www.thedataschool.co.uk/content/images/2023/10/DB98346A-7F9D-4557-95AD-2883D92D8C70_1_201_a-1.jpeg)
![](https://www.thedataschool.co.uk/content/images/2023/10/8A884C3D-F5DA-4AB4-8E6D-8F3E2F429996_4_5005_c-2.jpeg)