Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
jburbano
Frequent Visitor

Failing to build dynamic ODBC connection using Odbc.Query and a set parameter

I have a local ODBC driver for ServiceNow and I am trying to pull only the sc_req_item rows that have a matching [task] dv_parent:

 

 

 

let
     ODBCQueryString = """SELECT * FROM sc_req_item#(lf)WHERE (number IN (""" & Text.Combine(Table.Column(Table.SelectRows(Tasks, each [dv_parent] <> null and [dv_parent] <> ""), "dv_parent"), """,""") & """)) AND (sys_created_on >= TIMESTAMPADD(SQL_TSI_YEAR, -5, NOW()))""",
     Source = Odbc.Query("dsn=ServiceNow", ODBCQueryString)
in
     Source

 

 

 

From the Tasks table I am selecting rows that dv_parent is not empty, converting to list and combining with '","'. For a short example, the returning string is:

 

"SELECT * FROM sc_req_item
WHERE (number IN ("RITM0247413","RITM0383048","RITM0349498")) AND (sys_created_on >= TIMESTAMPADD(SQL_TSI_YEAR, -5, NOW()))"

 

But I am getting the following error:

 

jburbano_0-1675448576866.png

That list of RITM numbers may change and I need to dynamically create that list

1 REPLY 1
lbendlin
Super User
Super User

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.