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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Badeend
New Member

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

@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

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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