KNOWLEDGE BASE

Extracting Character Delimited Substrings From Strings


Published: 13 Dec 2013
Last Modified Date: 23 Oct 2017

Question

How to extract a string of characters, delimited by specific start and end characters, from a larger string of characters.

Environment

Tableau Desktop

    Answer

    The following instructions describe how to extract a sub string from a long string of characters and can be reviewed in the attached workbook.
    1. Select Analysis > Create Calculated Field.
    2. In the Calculated Field dialog box that opens:
      • Name the calculated field. In the example workbook, the calculated field is named Locate String.
      • In the formula field, create a calculated field similar to the following:
        MID([<Dimension>],FIND([<Dimension>],'<Identifying Character 1>')+1,
        FIND([<Dimension>],'<Identifying Character 2>'))
    3. Click OK.
    4. Select Analysis > Create Calculated Field.
    5. In the Calculated Field dialog box that opens:
      • Name the calculated field. In the example workbook, the calculated field is named Substring.
      • In the formula field, create a calculated field similar to the following:
        LEFT([Locate String],LEN([Locate String])-1)
    6. Click OK.
    7. Drag Substring to the Rows shelf.

    Additional Information

    • The MID Function combined with the FIND Functions will extract the sub string in between the two identifying characters
    • The second calculation, "Substring" will remove the second Identifying character from the end of the sub string
    • "Identifying Character 1" would be at the beginning of the desired sub string
    • "Identifying Character 2" would be at the end of the desired sub string.
    Did this article resolve the issue?