Tableau String Split Function

The Tableau split function is one of the string functions that helps split or divide the string and returns the part of a string based on the sequence and token_number.

This article shows how to use this Tableau SPLIT function to split the string and extract its parts or words. It also covers the alternative approaches such as the LEFT(), FIND(), and MID()functions to split strings.

Tableau String Split Function

The syntax of the Tableau split string function is as shown below.

SPLIT(Original_String_Column, Sequence, token_number)

If you observe the above syntax, the Tableau SPLIT function uses the Sequence to split the Original String Column into multiple parts (Substrings). Next, based on the token_number, it returns the part.  

  1. Original_String_Column: Actual column or string field.
  2. Sequence: You have mentioned the Sequence to split the string—for instance, space, comma, hyphen, delimiter, or even series of characters.
  3. token_number: An integer number will decide which part of the splitter string has to return. For instance, 1 means text before the first occurrence of the sequence. Three means text before the 4th sequence occurred. 

Original_String_Column = Hi Hello How are you

Sequence = ” ” (Empty space)

token_numbers

  • 1 = Hi
  • 2 = Hello
  • 3 = How
  • 4 = are
  • 5 = you

We used the below report to demonstrate this Tableau split string function and hide the Filters, Pages, and Marks Shelf using the Worksheet Menu. Drag and drop the Customer Name from the Sample Superstore Excel Source into the Rows shelf to create the same report. Next, add Sales to the Columns shelf, choose the Bar chart from the Show Me window, or change the Mark type to Bar. We have also added the Data labels to the Bar chart by clicking the T button.

A Simple Bar Chart with Data labels

Tableau String split function Example

To write the built-in SPLIT() function, you must create a calculated field. Go to the Analysis Tab, choose Create a calculated field option, and write the following Tableau expression.

SPLIT([Customer Name], ' ', 1)

The above expression splits the Customer Name using a space and returns the first part of the Name, i.e., before the first space (First Name).

Create a Calculated Field to write expression

Please add the FirstName calculated field to the table to see the output. Next, create one meow calculated field for the LastName. For more string functions >> Click Here! ad the remaining function >> Use this.

The below expression returns the second part of the Customer Name, i.e., before the second space (Last Name).

SPLIT([Customer Name], ' ', 2)
Tableau String Split Function to return First Name

Let me add the LastName to the table to see the First and Last Names generated by the SPLIT function.

Tableau String Split Function to extract First and Last Names from Customer Name

Tableau String split using LEFT, FIND, and MID functions

Instead of creating new ones, let me duplicate the FirstName and LastName calculated fields so that we can edit them. To do so, right-click on them and choose the Duplicate option.

Right-click on the FirstName(Copy) calculated field and choose the Edit option to change the expression. Here, the below expression uses the LEFT and FIND functions. The FIND function returns the first position of the space within the Customer Name. The LEFT function returns the characters from the start to the integer value returned by the FIND()function, i.e., the first space index position.

LEFT([Customer Name], FIND([Customer Name], " "))
Use Tableau LEFT and FIND functions to split string

The MID function starts at the position returned by the FIND() function and returns the whole string from that point.

MID([Customer Name], FIND([Customer Name], " "))
Use Tableau MID and FIND functions to split string and extract part of it

As you see from the screenshot below, the SPLIT String, LEFT, and MID functions return the same result.

Tableau String Split Function and alternatives