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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Anonymous
Not applicable

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 :

 

Example script.jpg

 

I am getting the below error : 

 

erreur.jpg

 

Has anyone encountered the same issue ?

 

Thank you,

Arnaud

1 ACCEPTED SOLUTION

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

View solution in original post

7 REPLIES 7
v-deddai1-msft
Community Support
Community 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

Anonymous
Not 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

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

Anonymous
Not applicable

Thank you!!

amitchandak
Super User
Super 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/

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Anonymous
Not 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

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.

 

Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 community update carousel

Fabric Community Update - June 2025

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