Step-by-Step Guide on Calculated Fields-String Functions in Tableau

Step-by-Step Guide on Calculated Fields-String Functions in Tableau

This blog is an easy-to-read article on String Functions in Tableau’s Calculated Field. Previously, we have covered many other functions in Calculated Fields, like Logical Functions, Date Function and Aggregate Functions. These step-by-step articles are meant for beginners who wish to be well acquainted with functions in Tableau. In fact, these blogs are great for all Tableau enthusiasts who want to explore the numerous amazing features available in Tableau.

So, let’s begin exploring String Functions.

Firstly, get to the Calculated Field window following the steps explained in the previous blog posts. Next, select the option ‘’String’’ from the Functions drop-down menu to view all the string functions.

ASCII Function

ASCII(string)

This function is used to return the ASCII code for the first character in a string. Example:

CHAR Function

CHAR(integer)

This function works in the reverse of ASCII function. CHAR function is used to change an integer ASCII code to a character. Example:

CONTAINS Function

CONTAINS(string, substring)

The CONTAINS function gives back the value TRUE if a string contains a specific substring and FALSE if it doesn’t contain it. Example:

ENDSWITH Function

ENDSWITH(string, substring)

This works in a similar way to the function described above. The function is used to indicate if a string ends with a selected substring or not, returning either TRUE or FALSE. Example:

FIND Function

FIND(string, substring, [start])

The FIND function is used to get the starting position of a substring within a string. The first character of the string is position 1. In case the substring is not located, then it returns the value 0. Example:

If the start argument is defined, any instance of the substring appearing before the start shall be ignored. Here’s an example:

ISDATE Function

ISDATE(string)

This function performs a logical test and is also included in the set of logical functions and date functions. It is used to test a string and determine if it is a valid date or not. Example:

LEFT Function

LEFT(string, num_chars)

A number is specified and using that this function returns the characters in the string. Example:

Incase start_of_week is excluded then it is determined based on the data source.

LEN Function

LEN(string)

This is the length function that is used to return the number of characters in a given string field. Example:

LOWER Function

LOWER(string)

This function is used to convert each and every character in a given string into lower case letters. Example:

LTRIM Function

LTRIM(string)

This function is used to remove spaces at the beginning of a string. Example:

MAX Function

MAX(a, b)

The Max function is included in many categories of functions. When used as a string function, the MAX function gives back the value that is highest in the sort sequence, which is defined by the database for that field’s column. If the field is NULL, then the function returns the value NULL. Example:

MID Function

MID(string, start, [length])

The MID function is used for obtaining characters from the middle of a text string. The start argument states the beginning of the returned value and the length argument gives the number of characters that is to be returned. In case the length isn’t included, then all the characters from the start position is considered. The first character in a string position is 1. Example:

MIN Function

MIN(a, b)

Works similary as the MAX function; the MIN function returns the minimum between a and b. Both must be of identical data type. With strings, the MIN function returns the lower value as per the sort sequence defined in the database. In case either of the argument is null, the function returns the value NULL. Example:

REPLACE Function

REPLACE(string, substring, replacement)

This function finds the occurrence of substring in a string and replaces them with the replacement string. If the substring cannot be located in the string then there’s no replacement. Example:

RIGHT Function

RIGHT(string, num_chars)

This works in reverse of the LEFT function. It gives back the characters starting at the end of a given string. And the amount of characters is determined by the argument giving the number of characters. Example:

RTRIM Functon

RTRIM(string)

This is similar to the LTRIM function and removes trailing spaces at the end of a string. Example:

SPACE Function

SPACE(number)

The SPACE function returns a string of spaces and the number of spaces is mentioned in the number argument. Example:

STARTSWITH Function

STARTSWITH(string, substring)

This works in reverse of the ENDSWITH function and returns TRUE or FALSE depending on whether a string starts with the given substring or not. Example:

TRIM Function

TRIM(string)

The TRIM function removes any leading or trailing spaces in a particular string. Example:

UPPER Function

UPPER(string)

The last function in the list of string function- the UPPER function works in reverse of the LOWER function. It is used to convert all the characters in the string to uppercase characters. Example:

This brings us to an end of the String functions. If you want to learn about the other functions in calculated fields then you must follow DexLab Analytics and check back for our previous blog posts.

This is the concluding blog of the blog series on Tableau’s Calculated Field functions. If you want to learn more about Tableau’s fantastic features then enroll for Tableau BI training courses. We offer professional Tableau certification in Delhi.

 
This article has been sourced from:
https://www.interworks.com/blog/ccapitula/2015/04/22/tableau-essentials-calculated-fields-string-functions
 

Interested in a career in Data Analyst?

To learn more about Data Analyst with Advanced excel course – Enrol Now.
To learn more about Data Analyst with R Course – Enrol Now.
To learn more about Big Data Course – Enrol Now.

To learn more about Machine Learning Using Python and Spark – Enrol Now.
To learn more about Data Analyst with SAS Course – Enrol Now.
To learn more about Data Analyst with Apache Spark Course – Enrol Now.
To learn more about Data Analyst with Market Risk Analytics and Modelling Course – Enrol Now.

July 6, 2018 11:10 am Published by , , , , , ,

, , ,

Comments are closed here.

...

Call us to know more

×