2 Replies Latest reply on Oct 29, 2016 12:53 PM by Jambesh Mahapatra

    data formatting question

    David Lu

      I have a pretty extensive data sheet that I would like to create some more columns for.  Right now the column labeled Code stores all the Agency codes in one column, but I would like to create some hierarchy here for easier drill downs in my visualizations.  



      Ideally, I would like some break outs that look like this:



      Is there an easy way to do this within Tableau?

        • 1. Re: data formatting question
          Sherzodbek Ibragimov


          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.


          • 2. Re: data formatting question
            Jambesh Mahapatra

            Hi David,


            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 .

            Like Below



            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