Forum Discussion

Badeend's avatar
Badeend
New Member
4 years ago

Query SQL server from Powerbi and get filtered results

Hi,

 

I assume that my question might be straight forward but I have been reading forum and blog posts for 2 hours and can't get it to work. 

 

I'm trying to get data from an sql server which has a very big amount of rows. 

If I understand the direct import from PowerBI it tries to import the entire database. 

I tried this a couple of times but stopped the program after a couple of hours because it kept importing.

What i need to get this to work is to filter the query, for example where timestamp > '2022/01/01'.

This would limit the rows sufficiently.

 

I would like to do this dynamicaly so i can change the query everytime.

For this i used Power Query Editor and in the advanced editor i tried this:

 

let
Source = Sql.Databases("Servername",[query="SELECT * FROM [PRODPLAN].[dbo].[Actualstops]"])
in
Source

 

Here I get this error:

DataSource.Error: Microsoft SQL: This function doesn't support the query option 'query' with value '"SELECT * FROM [PRODPLAN].[dbo].[Actualstops]"'.
Details:
SELECT * FROM [PRODPLAN].[dbo].[Actualstops]

 

I checked google for this error and one of the possible fixes is to turn of encryption. 

This did not work.

 

I it possible to show me how to get a query that is possible to be parameterised by timestamp?

 

Thanks in advance,

1 Reply

  • Badeend , have you written this query while creating the connection or later added the code.

     

    If you have added sql later. Just create a new connection with query in the advance option and check