Forum Discussion

tecumseh's avatar
tecumseh
Resolver III
3 years ago
Solved

Pass Parameters to SQL Queries

Hi all, I am trying to pass parameters to a SQL Query I found this article by Chirs Webb I have parameters in Power Query from a Parameter Table on my worksheet. Both parameters show as a cale...
  • tecumseh's avatar
    3 years ago

    Created the ODBC Connection to Google Big Query and configured it per Admin. Added a simple SQL Statement to the ODBC Query in PQ.
    Had already created a parameter table and I brought in Begin_Date as a date parameter in Power Query.
    Opened the advanced editor and edited the SQL String as this:


    Source = Odbc.Query("dsn=GoogleBigQuery", "#standardSQL#(lf)#(lf)select *#(lf)#(lf)from `server.database.table`#(lf)#(lf)where date between '" & Date.ToText(Begin_Date,"YYYY-MM-DD") & "' and '" & Date.ToText( Date.EndOfMonth(Begin_Date),"YYYY-MM-DD") & "'"),

     

    Where Begin_Date is the name of the date parameter coming from the parameter table.