2 Replies Latest reply on Sep 20, 2018 7:09 AM by Agustin Leira

    How to replicate an 'SQL IN' in Tableau ?

    Agustin Leira

      Hi everybody, how are you?

       

      I have this sentence in sql:

       

        case

          when ship.shp_service_id in

            (21, 23,22 ,261 ,262 ,821,691,1041,293,841,741,291,1061,292,263,264,11,101,102,103,282,761,161,991,104,105,106,107,108,109,110,751,1051,1171,301,871,1031,891,135551,292,102,103,101,1061,291,601,1151,721,1141,981,731,521,212,511,191,331,171,771,181,1071,281,971,

          61,62,63,64,81,441,442,351,831,451,591,153,154,311,422,341,611,251,312,931,1091,241,391,941,201,231,951,392,961,1101,901,1111,1121,461,371,462,361)

            then 'Domicilio'

          when ship.shp_service_id in

            (1081,781,1011,1161,811,1021,1001,791,443,832,801,321,911,921,851,681,671,431,881,1132,381,151,152,1131,581,1191,1181)

            then 'Sucursal'

            else 'clasificar'

          end as tipo_destino,

       

      And I Need replicate this logic in tableau. I have the field shp_service_id obviously.

       

      What is the best way ?

       

      I don't want to do: if shp_service_id=21 or shp_service_id=22 or ...

       

      Thanks a lot !!

        • 1. Re: How to replicate an 'SQL IN' in Tableau ?
          meenu choudhary

          Hi,

           

          You can use below logic:

           

           

          SYNTAX :  IF contains("List of values",[Column Name])=true THEN 'A' ELSE 'B' END

           

           

           

           

          IF contains("21, 23,22 ,261 ,262 ,821,691,1041,293,841,741,291,1061,292,263,264,11,101,102,103,282,761,161,991,104,105,106,107,108,109,110,751,1051,1171,301,871,1031,891,135551,292,102,103,101,1061,291,601,1151,721,1141,981,731,521,212,511,191,331,171,771,181,1071,281,971,

          61,62,63,64,81,441,442,351,831,451,591,153,154,311,422,341,611,251,312,931,1091,241,391,941,201,231,951,392,961,1101,901,1111,1121,461,371,462,361",STR(ID))=true

          THEN 'Domicilio'

          ELSEIF contains("1081,781,1011,1161,811,1021,1001,791,443,832,801,321,911,921,851,681,671,431,881,1132,381,151,152,1131,581,1191,1181",STR(ID))=true

          THEN 'Sucursal'

          ELSE "clasificar"

          END

           

           

          • 2. Re: How to replicate an 'SQL IN' in Tableau ?
            Agustin Leira

            Perfect, thank you !!!!