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
Anonymous
Not applicable

How to update dataflow M scripts from JSON file?

Hi,

I have created a dataflow in a developer workspace, then exported the dataflow as a JSON file and imported the dataflow from the JSON file into a production workspace, all successfully. Then I have made changes to the M code of the dataflow in the dev workspace. Now I want to export the JSON file from dev workspace and update the dataflow in prod workspace with the changed M code from the JSON file.

 

Is there a way to update an existing dataflow from a JSON file instead of creating a new dataflow from the JSON file?

 

The relevant difference is that if I delete the prod dataflow and import the JSON file as new, I would have to change all the datasets depending on the old dataflow to load from the new dataflow ID, which I want to avoid.

 

Thank you very much!

 

BR

Martin

8 REPLIES 8
Poojara_D12
Super User
Super User

Hi 

Currently, Power BI does not provide a direct method to update an existing dataflow in a workspace using a JSON file without creating a new dataflow. When you export a dataflow as a JSON file and then import it into another workspace, it creates a new dataflow with a new ID, even if the name is the same. This means that datasets or reports connected to the original dataflow will not automatically switch to the new one, leading to broken links unless they are manually repointed. Unfortunately, Power BI does not support updating or overwriting an existing dataflow via JSON import in a way that retains the original dataflow ID. To work around this, you would need to manually update the M code within the existing dataflow in the production workspace using the Power BI Service interface or through the Power BI REST API (if supported), thereby preserving the original dataflow ID and avoiding the need to rebind dependent datasets.

 

Did I answer your question? Mark my post as a solution, this will help others!
If my response(s) assisted you in any way, don't forget to drop me a "Kudos"

Kind Regards,
Poojara - Proud to be a Super User
Data Analyst | MSBI Developer | Power BI Consultant
Consider Subscribing my YouTube for Beginners/Advance Concepts: https://youtube.com/@biconcepts?si=04iw9SYI2HN80HKS
FADAVI
Frequent Visitor

Hi, 

I know it is an old post, it seems it's still impossible to overwrite a DF with a JSON template. 

There is a little tip to help:
In your queries which use the DF connector you can change the navigation steps in order to mention the dataflowName instead of the dataflowId.
Example:

let
   Source = PowerBI.Dataflows([]),
   WS = Source{[workspaceName="your_workspace_name"]}[Data],
   DF = WS{[dataflowName="your_dataflow_name"]}[Data]
in
   DF


If you do that you can delete the old DF and import the JSON file with the updated version. You will not have to modify the queries wich mention this DF.

Florian 

Anonymous
Not applicable
v-kkf-msft
Community Support
Community Support

Hi @Anonymous ,

 

After testing, I think you can try to directly copy the updated M code in development workspace to the Advanced editor of the dataflow in production workspace. That will update an existing dataflow from a JSON file instead of creating a new dataflow from the JSON file.

 

image.png

 

If the problem is still not resolved, please provide detailed error information or the expected result you expect. Let me know immediately, looking forward to your reply.

Best Regards,
Winniz

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

Anonymous
Not applicable

Hi @v-kkf-msft ,
Thank you for the support. This is actually what I currently do. But since I have multiple queries that I want to update in the dataflow, this is way more effort than importing all changes from one JSON file at once.

Do you know whether changing the M code of the queries in the dataflow can be automated through Power BI API with Pro or Premium per User license?

Best regards,
Martin 

Hi @Anonymous ,

 

Unfortunately, according to the document https://docs.microsoft.com/en-us/rest/api/power-bi/dataflows , it should be impossible to use Rest API to automatically update the M code.

 

Best Regards,
Winniz

@v-kkf-msft this is not correct.  There is a REST api that updates the M/PQ code for dataflows.  It is part of the "imports" API.  It doesn't work very well, and is pretty buggy.  But it is there.

Anonymous
Not applicable

Hi @v-kkf-msft ,

Thank you! This confirms my research. It seems the API doesn't know anything like a "Query" object in a dataflow, only dataflow level settings affecting all queries. I'll submit the JSON update as an idea.
BR
Martin

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.