1 Reply Latest reply on Jun 18, 2018 7:30 PM by lei.chen.0

    Tableau SQL to parse multiple values in parameter

    Youwei Chen

      I need pass multiple values from parameter to my DB2 database using IN clause.

       

      The parameter is comma separated list items:  "item1,item2".

      In SQL, I have  "select col from tab where item in ( (<Parameters.Items_Param>)

      It works if I only have one item: item1.    Multiple items don't work, anyone know of a solution?

      Is there some quote/unquote logic I can do to make it work? DB2 have a replace function.

       

      The list I have is small, 8 choices, would it be advisable to create 8 parameters, and pass all 8 parameters to query?

       

      I also tried with parameter with list of choices, however, it seem I cannot select multiple values in parameter.

       

      Thanks,

        • 1. Re: Tableau SQL to parse multiple values in parameter
          lei.chen.0

          Hello Youwei,

           

          As you might have noticed the difference between the two SQL clauses.

           

          select col from tab where item in ("item1", "item2")

          select col from tab where item in ("item1,item2")

           

          It seems that there's no equivalent in DB2 to string_split function as in SQL Server.

          Hope someone else familiar with DB2 could provide a solution.

           

          Or simply create 8 parameters, simple but troublesome

           

           

          Regards

          Lei