String Functions in Tableau: Find, Trim, Contains, Min

# String Functions in Tableau: Find, Trim, Contains, Min

clickHere
Vikram Singh
Assistant Manager - Content
Updated on Apr 10, 2022 21:37 IST

In this article, we will discuss string data type and different string function in Tableau.

## Introduction

Tableau support many types of function fo used in Tableau calculation like Number, String, Date, Type conversion, Logical,  Aggregate, User, Spatial, Predictive modelling, additional, format() function etc.

## String Data Type

• Text Data type
• Characters are enclosed in single or double quotes
• “Shiksha Online” or ‘Shiksha Online’
• String values are of two types:- Char and Varchar

### Char Data Type

• The length of the string is pre-defined or fixed
• i.e. if you enter the value greater than defined it will show an error
• Stores alpha-numeric values

### Varchar Data type

• Varchar stands for Variable character
• The length of the string is variable
•  i.e. you can enter as many values as you want
• Stores alpha-numeric values

## String function in Tableau

### 1. ASCII

• Returns the first character of the string
• Syntax: ASCII (string)
• Eg: ASCII (‘A’) = 65

### 2. CHAR

• Returns the character encoded by the ASCII code number
• Syntax: CHAR (number)
• Eg: CHAR (65) = ‘A’

### 3. CONTAINS

• Returns true if the given string contains the specified substring.
• Syntax: CONTAINS(string, substring)
• Eg: CONTAINS (“Naukri”, “kri”) = TRUE

### 4. FIND

• Returns the index position of the substring in the string if found otherwise 0.
• The position of the first character in the string is 1
• Syntax: FIND(string, substring, [start])
• Eg:
• FIND (“Naukri”, “Learning”) = 0
• FIND (“Learning”, “ing”) = 6
• FIND (“Learning”, “n”, 6) = 7

### 5. FINDNTH

• Returns the position of the nth occurrence of a substring
• Syntax: FINDNTH(string, substring, occurrence)
• Eg: FINDNTH(“Learning”, “n”, 2) = 7

### 6. LEN

• Returns the length of the string
• Syntax: LEN (string)
• Eg: LEN(“Naukri”) = 6

### 7. LEFT

• Returns the leftmost number of characters in the string
• Syntax: LEFT (string, number)
• LEFT (“Naukri”, 3) = “Nau”

### 8. RIGHT

• Returns the rightmost number of characters in the string
• Syntax: RIGHT (string, number)
• RIGHT (“Naukri”, 3) = “kri”

### 9. LOWER

• Returns all the characters of the string in the lower case
• Syntax: LOWER(string)
• Eg: LOWER(“NAukRI) = “naukri”

### 10. UPPER

• Returns all the characters of the string in the upper case
• Syntax: UPPER(string)
• Eg: UPPER(“NAukRI) = “NAUKRI”

### 11.SPACE

• Returns a string that is composed of the specified number of repeated spaces
• Syntax: SPACE (number)
• Eg: SPACE (2) = “  ”

### 12. SPLIT

• Returns the substring from a string, using delimiter character to divide the string into a sequence of tokens
• Syntax: SPLIT(string, delimiter, token number)
• Eg: SPLIT(‘N-A-U-K-R-I’, ‘-’, 3) = ‘U’

### 13. REPLACE

• Replace the substring with a new substring in the original string
• Syntax: REPLACE(string, substring, replacement)
• Eg: REPLACE (“NaukriL”, “L”, “Learning”) = “NaukriLearning”

### 14. TRIM

• Returns the string with the starting and trailing spaces removed
• Syntax: TRIM(string)
• Eg: TRIM(“ Naukri ”) = “Naukri”

### 15. LTRIM

• Remove the space from the start of the string
• Syntax: LTRIM(string)
• Eg: LTRIM(“ Naukri”) = “Naukri”

### 16. UTRIM

• Remove the space from the trailing of the string
• Syntax: UTRIM(string)
• Eg: UTRIM(“Naukri ”) = “Naukri”

### 17. MAX

• Returns the maximum of ‘a’ and ‘b’ which has a maximum character
• Syntax: MAX(a,b)
• Eg: MAX(“Naukri”, “Learning”) = “Learning”

### 18. MID

• Returns the string starting at index position start
• Syntax: MID (string, start, [length])
• Eg:
• MID(“Learning” , 2) = “earning”
• MID(“Learning” , 2, 3) = “ear”

### 19. MIN

• Returns the maximum of ‘a’ and ‘b’ which has a minimum character
• Syntax: MIN(a,b)
• Eg: MIN(“Naukri”, “Learning”) = “Naukri”

### 20. STARTSWITH

• Returns TRUE if the string starts with the given substring
• Syntax: STARTSWITH (string, substring)
• Eg: STARTSWITH (“Naukri”, “N”) = TRUE

### 21. ENDSWITH

• Returns TRUE if the string ends with the given substring
• Syntax: ENDSWITH (string, substring)
• Eg: ENDSWITH (“Naukri”, “N”) = FALSE

## Conclusion

In this article, we have discussed strings functions in Tableau like Find, Min, Max, Replace, Trim etc.

Through a series of articles, we will cover all the topics in-depth with examples.

Number Functions in Tableau: Mathematical, Trigonometric
In this article, we will discuss number functions in tableau like mathematical and trigonometric function.
Data Types in Tableau
Tableau supports 7 types of data types String values, Date values, Date & Time values, Numeric values, Boolean values, Geographical values, Cluster or mixed values.
Dimension and Measure in Tableau
Tableau supports seven different data types and it tableau automatically assigns a data type and role to each column.