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

Did you hear? There's a new SQL AI Developer certification (DP-800). Start preparing now and be one of the first to get certified. Register now

Reply
Anonymous
Not applicable

Editting the Python Source code

Hi All,

 

I use Python to pre-process data before importing it to PowerBI. However, I'm having some troubles with editting the source code.

 

When I open "Edit Queries" and click on "Source" in the applied steps box (on the right), I am able to edit my Python source code. However, the issue is that sometimes, there is many tables. I don't want to have to edit the source code and copy and paste it for every single Data table created.

 

Is there a way where I can edit the source code once, and let it automatically flow through to every single data table generated from my Python script?

 

Thanks

2 REPLIES 2
v-lid-msft
Community Support
Community Support

Hi @Anonymous ,

 

We can try to define a query parameter and use it in the Python.Execute function to meet your requirement. It will change in every function after the parameter changed.


Best regards,

 

Community Support Team _ Dong Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
ibarrau
Super User
Super User

Hi, I'm not sure there is something exactly like you are asking, but you can consider using custom functions. If you want to reuse a code in multiple tables, you can create functions. In that way you are just changing the code in one pleace.

https://docs.microsoft.com/en-us/powerquery-m/understanding-power-query-m-functions

 

Regards, hope this helps.

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.


If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Happy to help!

LaDataWeb Blog

Helpful resources

Announcements
April Power BI Update Carousel

Power BI Monthly Update - April 2026

Check out the April 2026 Power BI update to learn about new features.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

FabCon and SQLCon Highlights Carousel

FabCon & SQLCon Highlights

Experience the highlights from FabCon & SQLCon, available live and on-demand starting April 14th.