String Functions in Tableau

FREE Online Courses: Click for Success, Learn for Free - Start Now!

1. Objective

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.

String Function in Tableau

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

ASCII(string)
The ASCII String functions returns the ASCII code for the first character in the string.
Example:
ASCII(“Alabama”) = 65
Read about Tableau Navigation in detail

ii. CHAR Function

CHAR(integer)
This String functions works in the reverse of the ASCII function. It converts an integer ASCII code into a character.
Example:
CHAR(65) = ‘A’

iii. CONTAINS Function

CONTAINS(string, substring)
The CONTAINS String functions will return a TRUE value if the string contains the substring and a FALSE if it does not.
Example:
CONTAINS(“InterWorks”, “Works”) = TRUE

iv. ENDSWITH Function

ENDSWITH(string, substring)
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.
Example:
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.
Example:
FIND(“Mississippi”, “iss”, 4) = 5
Read about How to install Tableau in detail

vi. ISDATE Function

ISDATE(string)
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.
Example:
ISDATE(“September 29, 2014”) = true

vii. LEFT Function

LEFT(string, num_chars)
This String functions returns the characters of the string using the specified number as the amount.
Example:
LEFT(“cheetah”, 4) = ‘chee’
If the start_of_week is omitted, then it is determined by the data source.

viii. LEN Function

LEN(string)
The LEN String functions (or length function) returns the character count of the given string field.
Example:
LEN(“Missouri”) = 8

ix. LOWER Function

LOWER(string)
This String functions converts all characters in the given string into lower case letters.
Example:
LOWER(“Tableau”) = “tableau”
Read about Tableau Data Extract – How to do Data Extraction in Tableau in detail

x. LTRIM Function

LTRIM(string)
This String functions will remove any spaces starting the string.
Example:
LTRIM(“ Harry”) = “Harry”

xi. MAX Function

MAX(a, b)
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.
Example:
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.
Example:
MID(“Stillwater”, 3, 2) = “il”

xiii. MIN Function

MIN(a, b)
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.
Example:
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.
Example:
REPLACE(“calculation”, “ion”, “ed”) = “calculated”

xv. RIGHT Function

RIGHT(string, num_chars)
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.
Example:
RIGHT(“Nebraska”, 6) = “braska”

xvi. RTRIM Function

RTRIM(string)
The partner function to LTRIM. The RTRIM String functions returns the string with any trailing spaces removed.
Example:
RTRIM(“Harry “) = “Harry”
Read about Joining Data in Tableau – Inner Join in detail

xvii. SPACE Function

SPACE(number)
The SPACE function returns a string with the number of spaces defined by the number argument.
Example:
SPACE(1) = “ “

xviii. STARTSWITH Function

STARTSWITH(string, substring)
This is the opposite of the ENDSWITH function, and it returns a TRUE or FALSE result if the string starts with the substring.
Example:
STARTSWITH(“Michigan”, “Mic”) = TRUE

xix. TRIM Function

TRIM(string)
The TRIM function removes any leading or trailing spaces from the string.
Example:
TRIM(“ Harry ”) = “Harry”

xx. UPPER Function

UPPER(string)
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.
Example:
UPPER(“nasa”) = “NASA”
Read about Dealing With Data Quality Problems In Tableau 

4. Conclusion

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 ChartTableau Area Chart
For reference

You give me 15 seconds I promise you best tutorials
Please share your happy experience on Google

follow dataflair on YouTube

Leave a Reply

Your email address will not be published. Required fields are marked *