i would use LEFT function
so you keep eve the same but you make two calculated fields
- level 1 code: LEFT(Code, 2)
- level 2 code: LEFT(Code, 4)
and bring these calculated fields to your biew
hope it helps.
Yes you can do that in Tableau with just a slight modification in your data, if you modify your "Code" column to introduce a Separator (- , : etc) in between it will be a simple Custom Split in the data connection window itself.
this is how i introduced two new columns from your Code Column alone.
How You can do this (Assume you introduce the separator as - in the column as shown above)
1) Once you connect to your data, from the drop down arrow in Code column, Select Custom Split.
use hyphen (- ) as separator and enter first 2 column like below
This will create two Columns Code-Split-1 & Code-Split-2 .
3) In the Code-Split-2 Column , Choose create a new Calculated field and use the below formulae
And Name the calculation to Level-2-Code.
4) Now you can hide the column "Code-split-2" which is not needed and rename the Code-split1 Column to "Level-1-Code"
Hope this helps