Reputation: 1205
I'm fetching data through an SQL statement in PowerQuery:
let
Source = Oracle.Database("sampleDB", [Query="SELECT * FROM mySampleTable WHERE CustomerID in (1,2,3,4,5)"])
in
Source
I need the SQL filter to be dynamic. So I have another query with a single cell containing a text string. For the example above, the single cell looks like => "1,2,3,4,5". This is why I want to build a dynamic SQL statement in PowerQuery that references that single cell from my other query.
I've tried the code below and other variants but none work!:
let
Source = Oracle.Database("sampleDB", [Query="SELECT * FROM mySampleTable WHERE CustomerID IN (" & MyReferenceQuery["SingleCell"] & ")"]
in
Source
How can I reference this other query?
Upvotes: 0
Views: 876
Reputation: 4144
If the text is in a single cell in a table, you need to access the value by specifying a column and a row-index, like below:
= Oracle.Database("sampleDB", [Query = "SELECT " & MyReferenceQuery[Column1]{0} & " FROM Table"])
Upvotes: 1