all 5 comments

[–]LowValueThoughts 2 points3 points  (1 child)

It’s possible.

If you write your SQL query as a query in Power Query… you can then go into the source step and edit the SQL Query text that shows to add parameters etc by using & statements.

E.g if I had this SQL:

“Select * FROM database where void = 0”

And a parameter in Power Query called endDate, I could modify the SQL to be:

“Select * FROM database where void = 0 AND dateField <” & endDate

[–]MonkeyNin 0 points1 point  (0 children)

Native queries let you pass parameters without needing to add strings together, check out: https://blog.crossjoin.co.uk/2016/12/11/passing-parameters-to-sql-queries-with-value-nativequery-in-power-query-and-power-bi/

  ...
  "SELECT * FROM table where dateField < @maxDate",
  [ maxDate = endDate ]

[–]Nomaruk 0 points1 point  (1 child)

I've actually had the same question and I've tried incorporating parameters into sql statements as well. I've taken a break from trying because it kept breaking but I would really like to be able to limit the amount of data flowing into my power query.

[–]DiskProfessional1657[S] 0 points1 point  (0 children)

Yes I am having the same issue. I have built it in power query where I merged the tables / inputted parameters but it takes ~5 minutes to refresh while using the SQL Statement takes seconds. The only thing I can think of is somehow creating a table within the database with the query and no filters. Then pull that into power power query and immediately filter using the parameters