Select Page

Consider the following scenario,

If we need to split these Customer Names into three columns with First Name, Middle Name and Last Name Columns, how do we achieve it in Tableau?

Also, I have written another blog on the Alteryx way of solving the problem.

This can be done through writing calculated fields.

Below are three calculated fields I discovered that work quite well in solving this problem.

Calculated field one:

//Customer First Name

TRIM( SPLIT( [Customer Name], ” “, 1 ) )

Calculated field two:

//Customer Middle Name

IF LEN([Customer Name]) – LEN(REPLACE([Customer Name],” “,””)) > 1 then

//Check if there are more than one spaces indication of a middle name present

TRIM( SPLIT( [Customer Name], ” “, 2 ) )

ELSE

“”

END

Calculated field three:

//Customer Last Name

IF LEN([Customer Name]) – LEN(REPLACE([Customer Name],” “,””)) > 1 then

//Check if there are more than one spaces indication of a middle name present.

TRIM( SPLIT( [Customer Name], ” “, 3 ) )

ELSE

TRIM( SPLIT( [Customer Name], ” “, 2 ) )

END

Try out yourself! This works for me and should work for you too!

##### Author: Luke Yin

Before joining the Data School, Luke was a PhD researcher studying urban history of global cities at the University of Melbourne. Previously, Luke worked as an internal accountant for a Melbourne local winery. When conducting urban research, Luke discovered his passion for data visualisation and analysis through a number of university-based digital projects. Later, this became the reason for him to join the Data School. Luke wants to combine his expertise in research and business with data analysis to help solve real-world problems.