Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
5 years ago
Solved

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

    • Anonymous's avatar
      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

      • skp_pbi's avatar
        skp_pbi
        New 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-msft's avatar
    v-deddai1-msft
    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's avatar
      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

      • v-deddai1-msft's avatar
        v-deddai1-msft
        Community 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