String Functions in Tableau
Don't become Obsolete & get a Pink Slip
Follow DataFlair on Google News & Stay ahead of the game
In this Tableau tutorial, we are going out to learn about string functions in tableau. We will discuss all twenty Tableau String Functions including ASCII, CHAR, CONTAINS String functions with examples.
So let’s begin with String Functions in Tableau.
2. String Function in Tableau
An assortment of inbuilt string capacities are given by Tableau which empower string controls like looking at, connecting, supplanting characters from string, and so forth.
3. Functions in Tableau String Functions
i. ASCII Function
The ASCII String functions returns the ASCII code for the first character in the string.
ASCII(“Alabama”) = 65
Read about Tableau Navigation in detail
ii. CHAR Function
This String functions works in the reverse of the ASCII function. It converts an integer ASCII code into a character.
CHAR(65) = ‘A’
iii. CONTAINS Function
The CONTAINS String functions will return a TRUE value if the string contains the substring and a FALSE if it does not.
CONTAINS(“InterWorks”, “Works”) = TRUE
iv. ENDSWITH Function
A similar function to the one above, the ENDSWITH string functions tests if the string ends with the selected substring, returning either TRUE or FALSE.
ENDSWITH(“software”, “ware”) = TRUE
v. FIND Function
FIND(string, substring, [start])
The FIND string functions returns the start of the substring within the string. The first character in the string is position 1. If the substring is not found, it will return a value of 0.
FIND(“Oklahoma”, “la”) = 3
If the start argument is also defined, any instance of the substring that appears before the start will be ignored.
FIND(“Mississippi”, “iss”, 4) = 5
Read about How to install Tableau in detail
vi. ISDATE Function
This is a logical test that is also included in the list of logical functions. It tests a string to determine if it is a valid date (true/false). This String functions is also included in the Date Functions.
ISDATE(“September 29, 2014”) = true
vii. LEFT Function
This String functions returns the characters of the string using the specified number as the amount.
LEFT(“cheetah”, 4) = ‘chee’
If the start_of_week is omitted, then it is determined by the data source.
viii. LEN Function
The LEN String functions (or length function) returns the character count of the given string field.
LEN(“Missouri”) = 8
ix. LOWER Function
This String functions converts all characters in the given string into lower case letters.
LOWER(“Tableau”) = “tableau”
Read about Tableau Data Extract – How to do Data Extraction in Tableau in detail
x. LTRIM Function
This String functions will remove any spaces starting the string.
LTRIM(“ Harry”) = “Harry”
xi. MAX Function
The MAX function exists in several categories of functions, including String Functions. When used for strings, the MAX function returns the value that is highest in the sort sequence defined by the database for that field’s column. If either field is NULL, then the function will return NULL.
MAX(“Apple”, ”Banana”) = “Banana”
xii. MID Function
MID(string, start, [length])
The MID String functions returns the characters from the middle of a text string. The start argument is where the returned value will begin and the length argument is how many characters will be returned. If the length is not included, then all remaining characters after the start position will be included. The first character in the string is position 1.
MID(“Stillwater”, 3, 2) = “il”
xiii. MIN Function
Similar to the MAX function, the MIN function returns the minimum between a and b, which must be of the same data type (i.e. string). With strings, the MIN function will return the lower value based on the sort sequence as defined in the database. If either argument is NULL, then this String functions will return NULL.
MIN(“Apple”, “Banana”) = “Apple”
Read about Tableau Field Operations in detail
xiv. REPLACE Function
REPLACE(string, substring, replacement)
This String functions will replace find any occurrence of the substring in the string and replace those characters with the replacement string. If the substring is not found in the string, then there is no change.
REPLACE(“calculation”, “ion”, “ed”) = “calculated”
xv. RIGHT Function
This String functions is the opposite of the LEFT function. It returns the characters from the end of a given string, the amount determined by the number of characters argument.
RIGHT(“Nebraska”, 6) = “braska”
xvi. RTRIM Function
The partner function to LTRIM. The RTRIM String functions returns the string with any trailing spaces removed.
RTRIM(“Harry “) = “Harry”
Read about Joining Data in Tableau – Inner Join in detail
xvii. SPACE Function
The SPACE function returns a string with the number of spaces defined by the number argument.
SPACE(1) = “ “
xviii. STARTSWITH Function
This is the opposite of the ENDSWITH function, and it returns a TRUE or FALSE result if the string starts with the substring.
STARTSWITH(“Michigan”, “Mic”) = TRUE
xix. TRIM Function
The TRIM function removes any leading or trailing spaces from the string.
TRIM(“ Harry ”) = “Harry”
xx. UPPER Function
Finally, the UPPER function works in opposite to the LOWER function. It takes all the characters in the string and converts them to uppercase characters.
UPPER(“nasa”) = “NASA”
Read about Dealing With Data Quality Problems In Tableau
In this Tableau tutorial, we learned about various string functions in Tableau, different Tableau string functions: ASCII Function, CHAR Function, CONTAINS Function, ENDSWITH Function, FIND Function, ISDATE Function, LEFT Function, LEN Function, LOWER Function, LTRIM Function, MAX Function, MID Function, MIN Function, REPLACE Function, RIGHT Function, RTRIM Function, SPACE Function, STARTSWITH Function, TRIM Function, UPPER Function with examples. Which we can work with and many other things important for this topic.
See Also- Tableau Line Chart & Tableau Area Chart