Forum Discussion
Use SQL variables in Snowflake with ODBC connector
Hello Power BI Community,
I am trying to import data in Power BI from a Snowflake database.
Since the Snowflake connector doesn't allow to pass SQL statements, I am using a ODBC connector to pass my SQL scripts.
As soon as I don't use variables, it's working well but when I enter SQL scripts with variables like below :
I am getting the below error :
Has anyone encountered the same issue ?
Thank you,
Arnaud
Hi Anonymous ,
The parameter can't be directly used in sql statement window, you need to modify it in anvanced editor. Please refer to Use Case 2: Loading Dynamic Columns from the Data Source in https://www.biinsight.com/power-bi-desktop-query-parameters-part-1/
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Best Regards,
Dedmon Dai
7 Replies
- amitchandakSuper User
Anonymous , I think you should pass the parameter like
https://powerbi.microsoft.com/en-us/blog/deep-dive-into-query-parameters-and-power-bi-templates/
- AnonymousNot applicable
Hi amitchandak . Thanks but I can't use this option. The script I want to use has 12 joins on massive tables with parameters dependancies and importing those massive tables would not be possible so I really need to include parameters in the SQL statement and so import 1 single table in Power BI
- skp_pbiNew Member
Hi Anonymous - Were you able to solve? We have similar requirement re massive table joins that need parameter driven filtering. Was thinking would be able to inject filter parameters via advanced editor as implied in above discussion.
- v-deddai1-msftCommunity Support
Hi Anonymous ,
Would you please try something like :
Odbc.Query("dsn=xxxx", "Select * from xxxxx where xxxxx="&Parameter&"")If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Best Regards,
Dedmon Dai
- AnonymousNot applicable
Hello v-deddai1-msft , thanks, I think it could work as a workaround but to make it simple, I would like to declare and use variables directly in the SQL statement
- v-deddai1-msftCommunity Support
Hi Anonymous ,
The parameter can't be directly used in sql statement window, you need to modify it in anvanced editor. Please refer to Use Case 2: Loading Dynamic Columns from the Data Source in https://www.biinsight.com/power-bi-desktop-query-parameters-part-1/
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Best Regards,
Dedmon Dai