2 Replies Latest reply on Mar 28, 2016 6:35 AM by pooja.gandhi

    Hello How can i use case with in condition

    mehul parekh

      Case when [order number] like any ('DE%','FL%','TX%','CA%')  THEN "DO NOT COUNT" ELSE "COUNT" END ..

      this is giving error and I cannot figure out why , can u please guide me ?

      Thank you

        • 1. Re: Hello How can i use case with in condition
          Bill Lyons

          "Like" is not a valid Tableau operator or function, neither is "any" or "in" or wildcard characters. This should work for you:

          CASE

               WHEN STARTSWITH([Order Number],'DE') THEN "DO NOT COUNT"

               WHEN STARTSWITH([Order Number],'FL') THEN "DO NOT COUNT"

               WHEN STARTSWITH([Order Number],'TX') THEN "DO NOT COUNT"

               WHEN STARTSWITH([Order Number],'CA') THEN "DO NOT COUNT"

               ELSE "COUNT"

          END

          • 2. Re: Hello How can i use case with in condition
            pooja.gandhi

            Bill's suggestion works, but you can limit the then condition by converting CASE to IF/THEN also to make it somewhat shorter:

             

            IF STARTSWITH([Order ID], 'DE')

            OR STARTSWITH([Order ID], 'FL')

            OR STARTSWITH([Order ID], 'TX')

            OR STARTSWITH([Order ID], 'CA')

            THEN 'Do Not Count' else 'Count' END