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

can we execute all sql script in power query at once?

Hello,

I have a set of codes where I need to create some tables and get output. Is there any possibility to write all these codes and get the final output in the power query as a table?

@powerqueryquest @Snowflake 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hello @ImkeF ,

Thank you for your clarification. Let me share my experiance on this query.

After I did some research I found one solution to my problem.

that is called get data from query id (single line)

Let me explain it briefly 

1. There are multiple tables and conditions used in my code which is around 200 lines of code but I want the last 2 tables individually.

2. I have run the entire code (exept the last two tables)

3. once I run the table 1 once query id will generate so That is my keypoint

4. select last_query_id(-1) -- to get the query id

4. selct * from table (result_scan('Table1 QUERY ID')); - Entered this in power query sql code space and got the resulsts.

 

This is my story about my answer- self learning gives me a lot of satisfaction.

Thank you!

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Hello @ImkeF ,

Thank you for your clarification. Let me share my experiance on this query.

After I did some research I found one solution to my problem.

that is called get data from query id (single line)

Let me explain it briefly 

1. There are multiple tables and conditions used in my code which is around 200 lines of code but I want the last 2 tables individually.

2. I have run the entire code (exept the last two tables)

3. once I run the table 1 once query id will generate so That is my keypoint

4. select last_query_id(-1) -- to get the query id

4. selct * from table (result_scan('Table1 QUERY ID')); - Entered this in power query sql code space and got the resulsts.

 

This is my story about my answer- self learning gives me a lot of satisfaction.

Thank you!

ImkeF
Super User
Super User

Hello @Anonymous ,
yes, if you just expect one output table, you can write all your logic in one query.
In a query, every step name is like a variable. So you can create staging logic in certain steps and reference each step from whereever you need.
But if you want to create multiple queries at one go, this is not possible with a custom script.

Imke Feldmann (The BIccountant)

If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!

How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries

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.

Top Solution Authors