4 Replies Latest reply on Jan 5, 2018 8:58 AM by Dan Cory

    Not like in Tableau

    Vasudeva Veeragandham

      Hi Folks,

       

      I need help regarding case statement rewrite in tableau

      CASE

              WHEN Parameter  = 'False'

              AND service_name NOT LIKE '%_qa'

              THEN 1

              WHEN parameter =  'True'

              THEN 1

            END = 1

        • 1. Re: Not like in Tableau
          Mark Fraser

          Have you tried the contains function? then with NOT, as shown below

          • 2. Re: Not like in Tableau
            Dan Cory

            Since your like had a % sign only at the beginning, you actually want ENDSWITH.

             

            Also, you don't need to do the stuff with 1 in Tableau since it can handle Boolean fields directly. Just write:

            ((Parameter = 'False') AND (NOT ENDSWITH(service_name,'_qa'))) OR (Parameter = 'True')

            Assuming your parameter can only be True or False, the first clause is redundant, so you can just write:

            (NOT ENDSWITH(service_name,'_qa')) OR (Parameter = 'True')

             

            Dan

            • 3. Re: Not like in Tableau
              Vasudeva Veeragandham

              Hi Dan ,

               

              How write above mentioned in case statement in form below

               

              CASE

                      WHEN Parameter  = 'False'

                      AND service_name NOT LIKE '%_qa'

                      THEN 1

                      WHEN parameter =  'True'

                      THEN 1

                    END = 1

               

              Yours :

               

              ((Parameter = 'False') AND (NOT ENDSWITH(service_name,'_qa'))) OR (Parameter = 'True')

              • 4. Re: Not like in Tableau
                Dan Cory

                You can of course write:

                CASE ((Parameter = 'False') AND (NOT ENDSWITH(service_name,'_qa'))) OR (Parameter = 'True') THEN 1 END = 1

                 

                This will get optimized by recent versions of Tableau back to just the Boolean expression.

                 

                Dan

                1 of 1 people found this helpful