Forum Discussion
RSA_PBIHelp
3 years agoRegular Visitor
Use results from one table/query as SQL search string in new query
Hello, I am trying to find a clean way to pass along query results from Query 1 as a search string for Query 2 when the queries are not against the same DB or server. The following is a very...
Anonymous
3 years agoNot applicable
You can do this by first running Query1, and make the resulting column a list. Then combine the list into a single text value separated by commas. Finally, use Query1 as a parameter in an IN statement, so:
Text.Combine(Table.Column(PriorStepOrTableName), ", ")
That gives you your IN statement string, which you use in Query2 like:
"select b.ProductID, b.ProductUnitCost from tblB b where b.ProductID IN ("&Query1&")"
--Nate
RSA_PBIHelp
3 years agoRegular Visitor
Hello, thank you for your response. I tried this but got the following error: "Formula.Firewall: Query 'Query2' (step 'Source') references other queries or steps, so it may not directly access a data source. Please rebuild this data combination."