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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
aront
Helper I
Helper I

Storing Power Query M queries in Git?

So I realize many people come to Power BI from the Excel world. But I am sure there are lot's of people coming from the open source world. From our perspective a query is a little program and programs should be managed in a SCCS like Git. That way I can version queries, share them with others who can make changes and import them into whatever report I need them.

 

Here is another scenario where storing in something like Git is so important: In Excel and O365 you can store power queries in a Power BI site - but that is a disaster. I did it once, my Excel file crashed and I lost 2 hours of query work. I said to myself, great I saved them on O365 I can just reuse them - but of course all I got back was a link to some internal binary. The "original" query is stored in the Excel file but since that file crashed and burned without having a recoverable backup of the lost work - all that work went down the tubes.

 

I did find this little post online, but the approach seems to require you have the text file in a local directory, so I'm not sure its relevant for published reports on powerbi.com

 

Anyone have any good ideas besides copy/paste functions into reports?

 

If not, I will add it as a feture request and anyone interested can upvote it.

 

 

6 REPLIES 6
st_0999
Helper II
Helper II

This is a really good idea. 

I have so many queries with so many functions (as M-code), across workbooks. 

If I could maintain the functions in a Git, and just import them into the relevant workbooks, or dataflows (as a query that pulls in another query), it would save so much code duplication. 

 

For example now, if I have to modify one function, and I have 20 excel workbooks, I have to modify that function 20 times. 

 

Microsoft already do this for LAMBDAS, and normal excel formulas. I think, they should do it for Power Query and M-Code scripts too.

potyarkin
New Member

I too consider it essential to manage any source code with version control system. I was rather disappointed to find out there is no easy way to do so with Power Query.

 

That's why I have started the LibPQ project: https://github.com/sio/LibPQ/ It enables you to store source code in local files or on the web server, and to load those modules into your workbooks.

 

I hope you'll find it useful too.

curth
Power BI Team
Power BI Team

Please do file this as a feature request. Of course, nothing prevents you from storing code in GitHub and copying it manually into your query -- but this is obviously tedious and error-prone. I personally keep code samples at https://gist.github.com/CurtHagenlocher

Greg_Deckler
Community Champion
Community Champion

Are you referring to "Send to Data Catalog"?



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

When I was talking about the problems I had in Excel - yes I was referring to send to Data Catalog!

 

And I have opened a request for this feature.

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.