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
Anonymous
Not applicable

TSQL to Power query 'M'

Hello,

I have made a query in Power BI Desktop (power query editor).

Now I want to create another query based on that query. Since I am a beginner in Power Query I am not very good in 'M'. I do however have the query code in TSQL.

 

As far as I can understand, I cannot use TSQL to create a new query in Power Query...?

What is the best way to use/convert the TSQL code?

 

Thanks,

1 ACCEPTED SOLUTION

@Anonymous Create a new connection to sql server with TSQL code then view code of that under Advanced Editor and use that as a basis for your own query.

View solution in original post

4 REPLIES 4
v-yuezhe-msft
Employee
Employee

Hi @Anonymous,

What specific data do you want to get with the new query? You can review the following blog and article to get details about that how to retrieve or transfer SQL Server data with Power Query Formula Language.

Power Query Formula Language in Power BI Desktop
Power Query (informally known as "M") formula categories

Thanks,
Lydia Zhang

Community Support Team _ Lydia Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
ankitpatira
Community Champion
Community Champion

@Anonymous I am guessing you have TSQL code to connect and get data from SQL Server. If yes then why don't you use power bi default connector for SQL Server which lets you type in your TSQL code and query. That will also generate power query code for you automatically by using default connector.

Anonymous
Not applicable

Hello Ankitpatira, thank you for your interest.

I cannot use the TSQL code and connect to the SQL server, because the code is from another SQL server, and I have made a query in Power Query that includes the data that I need. So I need to make a new query from that table. 

@Anonymous Create a new connection to sql server with TSQL code then view code of that under Advanced Editor and use that as a basis for your own query.

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.