top of page
Search
  • Writer's pictureYuchen Liu

Splitting Strings is Easy With Tableau

Updated: Apr 23, 2020


Recently, I am working on a new project which allows me to use 'Split' function a lot in Tableau. As an analyst, you will find the data doesn't always come ready for analysis, you have to customize the filed as needed. The picture on the top is a good example, a store manager wants to separate 'Customer Name' into the first and last name. In Tableau, we can split data fields easily in different ways.


In the data source view, choose the field you want to split and click the arrow next to the field's name. Tableau will automatically split the city and state by comma when you click 'Split'.


Now let's explore another scenario, in the data source, we need the last 6 digits of 'Order ID'. Just click the arrow next to the 'Order ID' field and select 'Custom Split', and you'll see a pop-up window say 'How should this data split'? First, we type in the separator "-", and choose to split off 'Last 1' columns, then you will see a new column called 'Order ID - Split 1'.

🤪Yuchen's tip: Always rename the new split field will make your analysis easier!


Splitting is super flexible in Tableau, which also can be done in the analysis view (when you click 'sheet 1' next to the data source view).



Right click 'Order ID' and select 'Create Calculated Field'. Type in the formula SPLIT( [Order ID], '-', 2), then you will see a new dimension which returns the middle character (year) in 'Order ID".

🤪Yuchen's tip: When you create a new calculated field, don't forget to use the formula explainer. The examples give you a quick view to see how is the function working.


People who are familiar with Excel should know the function ' = Right ()' and '= Left ()'. Tableau has the same ones. We still take 'Order ID' as an example. Formula RIGHT([Order ID], 6) will return the last 6 digits of the 'Order ID'.


'Split' function is flexible in Tableau especially when calculations are applied to it. Please check different ways to do a split and have a great analysis with Tableau!


Happy analyzing!

31 views0 comments

Recent Posts

See All

Comments


bottom of page