If you want to import data from a SQL query instead of a table then this article will help you. Sometimes we have a very complex SQL query. So, if we create a table and populate it with this query and then import it in to the power BI it will take more time. So, we call this query directly in Power BI. Follow the below steps.
Step 1
I have three tables in my database and I have created a join query on these tables. In table 1 i.e. Sales.CurrencyRate I have the below data.

And table 2 i.e. Sales.Currency contains the below data
And table 3 i.e. Sales.CountryRegionCurrency has the data taht you can see in the below image.
So, I have created the below query using these table. See the below image for query and data.
Now I want to import the data using this query in Power BI.
Step 2
Go to ‘Home’ tab of Power BI and click on ‘Get Data’ drop down and further click on ‘Sql Server’. A new SQL Server database window will open. Provide server name and database name. Select ‘DirectQuery’ as data connectivity mode.
Expand ‘Advanced Option’ and paste your query in ‘Sql statement’. Click on ‘Ok’ to submit query.

Join the conversation! Your thoughts help the community grow.