Advance your Data & AI career with 50 days of live learning, dataviz contests, hands-on challenges, study groups & certifications and more!
Get registeredJoin us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM. Register now.
How do I write a query to select data from a SQL table? I mean an SQL statement to get specific data from te table.
Thanks
When you connect to SQL Server, expand the "Advanced options" as show in the screen shot below and then just paste in your SQL code.
That is when I import data. But about pulling data at real time?
Hi Markzolotoy,
Do you connect to the table from on-premises SQL Server database in Power BI Desktop and want to pull data at real time? If that is the case, there is no such feature in Power BI Desktop. However we can manually change query to select different data using Advanced Editor of Query Editor, for more details about Advanced Editor, please review the this article: https://powerbi.microsoft.com/en-us/documentation/powerbi-desktop-query-overview/ .
Moreover, we can utilize the Schedule Refresh feature to refresh dataset created from Power BI Desktop files imported from a local drive where Get Data/Query Editor is used to connect to and load data from on-premises SQL Server database. For more details, please review the following articles.
https://powerbi.microsoft.com/en-us/documentation/powerbi-refresh-desktop-file-local-drive/
https://powerbi.microsoft.com/en-us/documentation/powerbi-refresh-data/#understanding-data-refresh
Thanks,
Lydia Zhang
so if i wanted to select data from a view in a DB2 database, i cannot create a datasource of that nature is that correct? I have successfully created the data source for said DB2 connection and am able to pull all the data from the view but i would like to limit it further with SQL. Thanks
Should be essentially the same process. See the Advanced options here for DirectQuery from Azure SQL Database:
https://powerbi.microsoft.com/en-us/documentation/powerbi-azure-sql-database-with-direct-connect/
Advanced options provides a Custom filters section, and supplies an example of a SELECT statement.