2 Replies Latest reply on Aug 3, 2017 8:45 AM by edlira.stefani.0

    Compare dynamic string in two different columns

    edlira.stefani.0

      The two columns Attribute 1 and Attribut2 have text delimited by pipe |. How can I create a calculated column, comparing any text between pipes | | and return True if there is a match and False otherwise.

       

       

      Thank you

       

      Edlira

        • 1. Re: Compare dynamic string in two different columns
          Matt Lutton

          Hi there,

           

          I do not know the answer off the top of my head, but am thinking that if you cannot do this using regular Find, Replace, Mid, Left, Right, etc. string functions, then perhaps its worth exploring the Regular Expression language, since Tableau supports that.  It basically lets you create complex string pattern matching expressions, that allow for comparing fields on multiple possibilities:  Become a regular with regular expressions

           

          Not sure if that is helpful or not, but what have you tried thus far that has not worked?

          • 2. Re: Compare dynamic string in two different columns
            edlira.stefani.0

            Logic below is giving me what I want.

             

             

            IF CONTAINS([Column2],'| |') == FALSE THEN CONTAINS([Column1],[Column2])

            ELSEIF Contains([Column1],split([Column2],'| |',1)) and split([Column2],'| |',1) !='' THEN True
            ELSEIF Contains([Column1],split([Column2],'| |',2)) and split([Column2],'| |',2) !='' THEN True
            ELSEIF Contains([Column1],split([Column2],'| |',3)) and split([Column2],'| |',3) !='' THEN True
            ELSEIF Contains([Column1],split([Column2],'| |',4)) and split([Column2],'| |',4) !='' THEN True
            ELSEIF Contains([Column1],split([Column2],'| |',5)) and split([Column2],'| |',5) !='' THEN True
            ELSEIF Contains([Column1],split([Column2],'| |',6)) and split([Column2],'| |',6) !='' THEN True
            ELSEIF Contains([Column1],split([Column2],'| |',7)) and split([Column2],'| |',7) !=''THEN True
            ELSEIF Contains([Column1],split([Column2],'| |',8)) and split([Column2],'| |',8) !=''THEN True
            ELSEIF Contains([Column1],split([Column2],'| |',9)) and split([Column2],'| |',9) !=''THEN True
            ELSEIF Contains([Column1],split([Column2],'| |',10))and split([Column2],'| |',10) !='' THEN True
            ELSE False
            END

             

            Thank you

            Edlira

            1 of 1 people found this helpful