Search code examples
charactertableau-api

How do I remove text after a specific character in tableau?


I need to remove everything after a specific character in tableau. E.g.

xx.xxx.xxx.xxx will become xx.xxx, similarly if I have xxx.xxx.xx.xx it will become xxx.xxx. Basically I want to remove everything after the second ..

I have tried the below but it doesn't work.

IF CONTAINS([Dimension], '.') THEN
MID(
    [Dimension],
    FIND([Dimension],'.') + 1,
    FIND([Dimension],'.',2) - (FIND([Dimension],'.') +1)
)
END

I am getting Null when moving my calculated field in the rows part.


Solution

  • This formula should do it:

    LEFT([Dimension], FINDNTH([Dimension],".",2)-1)