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

The Fabric Community site will be in read-only mode on Monday, Feb 24 from 12:01 AM to 8 AM PST for scheduled upgrades.

Reply
jaryszek
Post Partisan
Post Partisan

How to import multiple power queries *.pq files into power bi?

Hi, 

i have a lot of power queries *.pq files created in Power Query SDK. 
How to import M Code from all of them as separated queries into Power Bi Desktop? 

So i have Query1, Query2, Query 3 M code tested and checked in power Query SDK. 
Now i want to get them in Power Query editor in Power BI with the same M code (replace or create new power queries while importing). 

How to do this?
Best,
Jacek


1 ACCEPTED SOLUTION

I solve the case!!

To programmatically interact with power queries you can modify existing M code using TMDL approach: 
https://powerbi.microsoft.com/en-us/blog/tmdl-in-power-bi-desktop-developer-mode-preview/ 

Best,
Jacek

View solution in original post

10 REPLIES 10
v-pnaroju-msft
Community Support
Community Support

Hi jaryszek,

Thank you for your valuable feedback. We understand that the lack of an automated solution poses a challenge, and we sincerely appreciate the efforts invested in exploring possible alternatives. While there is no officially documented method to automate this process, we encourage staying updated with Power BI developments and actively engaging in community forums, where new tools or solutions may be introduced.

In the meantime, if a feasible solution is discovered, we would appreciate it if it could be shared with the community, as it may benefit others facing similar challenges.We appreciate the patience and understanding.

Thank you.

v-pnaroju-msft
Community Support
Community Support

Hi jaryszek,

 

We are following up to see if your query has been resolved. Should you have identified a solution, we kindly request you to share it with the community to assist others facing similar issues.

If our response was helpful, please mark it as the accepted solution and provide kudos, as this helps the broader community.

Thank you.

I solve the case!!

To programmatically interact with power queries you can modify existing M code using TMDL approach: 
https://powerbi.microsoft.com/en-us/blog/tmdl-in-power-bi-desktop-developer-mode-preview/ 

Best,
Jacek

thanks! Query is not resolved yet because there is no option to automate the process. 

Looking for solution - if I will find it - i will close the topic.

Best,

Jacek

v-pnaroju-msft
Community Support
Community Support

Hi jaryszek,

 

Thank you for your acknowledgment.

 

Based on my research, I have not found any official documentation to automate the process using PowerShell or any other programming language. As an alternative, we can proceed with the proposed solution.

If you have discovered a method to automate the process, we kindly request you to share it with the community to assist others facing similar challenges.

 

If you find our response helpful, we kindly request you to mark it as the accepted solution and provide kudos. This will assist other community members encountering similar queries.

v-pnaroju-msft
Community Support
Community Support

Hi @jaryszek,

Thank you @BeaBF and @ZhangKun for your response.

We appreciate your inquiry through the Microsoft Fabric Community Forum.

 

To successfully import multiple Power Query (.pq) files into Power BI Desktop as separate queries, please follow the steps outlined below as a potential solution:

  1. Launch Power BI Desktop. Navigate to the Home tab and select Transform Data to open the Power Query Editor. In the Power Query Editor, click on Home > Advanced Editor.
  2. Open each .pq file using a text editor such as Notepad or Visual Studio Code. Modify the .pq files by removing the section or shared declarations. Copy the M code content from the .pq file.
  3. In the Power Query Editor, create a new blank query by selecting Home > New Source > Blank Query. In the new query, go to Home > Advanced Editor and paste the copied M code into the Advanced Editor.
  4. Ensure that each query has a unique name. The queries can be renamed in the Queries pane after their creation.
  5. Repeat the above steps for the remaining .pq files.

Additionally, if you find our response helpful, kindly mark it as the accepted solution and provide kudos. This will assist other community members encountering similar queries.

 

Thank you.

Thank you very much. 

There is no powerShell or different language to automate process? 

Best,
Jacek

ZhangKun
Super User
Super User

when you use a custom connector, you reference the contents of the connector. Because of this behavior, it is different from pasting code.

If you use Power Query in Excel, you can add code using VBA, VSTO..., but it may be difficult or impossible to do it in PowerBI.

BeaBF
Super User
Super User

@jaryszek Hi! Can you paste your advanced aditor code?

 

BBF

Hello, 

thanks! 
Why this is making difference what kind of M code i have?

 

let
    Source = #table({"Name", "Age"}, {  
        {"Alice", 25},  
        {"Bob", 30},  
        {"Charlie", 35}  
    })  
in
    Source

 

 

example 2:

 

let
    Source = #table({"Product", "Price"}, {  
        {"Laptop", 1000},  
        {"Phone", 600},  
        {"Tablet", 400}  
    }),
    AddedColumn = Table.AddColumn(Source, "Discounted Price", each [Price] * 0.9)
in
    AddedColumn

 

 

Mez file: 

section Section1;

shared MyQuery = 
let
    Source = #table({"Product", "Price"}, {  
        {"Laptop", 1000},  
        {"Phone", 600},  
        {"Tablet", 400}  
    }),
    AddedColumn = Table.AddColumn(Source, "Discounted Price", each [Price] * 0.9)
in
    AddedColumn;

 

Best,
Jacek

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

FebPBI_Carousel

Power BI Monthly Update - February 2025

Check out the February 2025 Power BI update to learn about new features.

Feb2025 Sticker Challenge

Join our Community Sticker Challenge 2025

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

Feb2025 NL Carousel

Fabric Community Update - February 2025

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

Top Solution Authors