1 Reply Latest reply on Nov 14, 2012 11:12 AM by Tracy Rodgers

    case statement with in and not in

    Ronak Patel

      in sql you can write case statement with [column] not in (1,2,3,4) or [column] in (1,2,3,4). does tableau support "in" and/or "not in" operators?

        • 1. Re: case statement with in and not in
          Tracy Rodgers

          Hi Ronak,


          Tableau does not use the 'in' syntax that SQl uses. However, the same outcome can be accomplished. For example, if this is the data:


          John Smith5/6/20048
          Allan Babel5/6/20048
          Tina Crown5/6/20048
          John Smith5/7/20049
          Allan Babel5/7/20048
          Tina Crown5/7/200410
          John Smith5/8/20048
          Allan Babel5/8/20048
          Tina Crown5/8/20049


          and the SQL statement is the following:


          SELECT *

          FROM EmployeeHours

          WHERE Date IN ('5/6/2004', '5/7/2004')


          The same results would be returned in Tableau with a calculation similar to the following:


          if [Date]=#5/6/2004# or [Date]=#5/7/2004# then [Employee] else 'hide' end


          Then, the calculation can be placed on the filter shelf and the 'hide' option can be excluded.


          Hope this helps!