cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Frequent Visitor

How to replace part of the M code in many queries at the same time

Hi,

 

I inherited the responsibility to maintain a large PowerBI file that has more than 80 queries.  It serves as a central dataset and presentation layer for many other reports.  The previous owner hardcoded the connection to the SQL server in each individual queries.  I want to use parameters.

 

Is it possible to do a search and replace to change the Source step in all the queries at once?

 

Something like this:

Search M code in all queries:     Source = Sql.Database("server1", "database1")

Replace M code in all queries:   Source = Sql.Database(ServerNameParam, DatabaseNameParam)

 

Thank you

 

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted

Hi @molegris ,

it requires a bit of setup, but then you can bulk-replace strings in your M-code at once: 
https://bengribaudo.com/blog/2020/07/16/5356/editing-report-spreadsheet-mashups-in-vscode

 

 

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

View solution in original post

3 REPLIES 3
Highlighted
Super User IV
Super User IV

@molegris , I doubt that. But let check with other super users

@ImkeF , can you help on this



Did I answer your question? Mark my post as a solution! Appreciate your Kudos!!
Dashboard of My Blogs !! YouTube Channel !! Connect on Linkedin

Proud to be a Super User!

Highlighted

Hi @molegris ,

it requires a bit of setup, but then you can bulk-replace strings in your M-code at once: 
https://bengribaudo.com/blog/2020/07/16/5356/editing-report-spreadsheet-mashups-in-vscode

 

 

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

View solution in original post

Highlighted

Thank you.  A bit complicated but I'll definitly try it and I'll let you know if it worked for me.

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

Community Conference

Microsoft Power Platform Communities

Check out the Winners!

secondImage

Create an end-to-end data and analytics solution

Learn how Power BI works with the latest Azure data and analytics innovations at the digital event with Microsoft CEO Satya Nadella.

Top Solution Authors
Top Kudoed Authors