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
rashmilikhite
New Member

Edit python script as datasource to update existing models

Hi,

I am fairly new to Power BI and need help with the following scenario.

 

- I am using Python Script as the datasource.

- This python script calls REST APIs internally with tokenA as the API token and creates 4 dataframes such as ModelA, ModelB, ModelC and ModelD.

- These dataframes are then treated as models in Power BI and I create report/dashboard from the data.

Screenshot (1).png

- Now, I want to edit the API token used in the python script to tokenB and save it. On saving, the 4 models should be updated with the new data.

- To achieve this, I tried to find a way to edit the Pyhton script source but could not find anything. So, I had to edit the Source of ModelD and save it.

Screenshot (2).png

-----

Screenshot (3) copy.png

- On doing this, the script returns 4 dataframes ModelA, ModelB, ModelC and ModelD again but now these dataframes gets assigned to ModelD. Instead, the output of dataframes should have mapped to the existing models which were created in the intial steps.

Screenshot (4) copy.png

 

The update of API token is just one scenario, there might be cases where I need to add/remove dataframes returned from the script?

Is there a way to edit the original python script which affects all the models which were created from this script?

 

Let me know if you need additional data to answer my query.

 

Regards

1 REPLY 1
lbendlin
Super User
Super User

You are running these four models four times each . It would be easier to run each model separately, and create only one dataframe which can map to exactly one query output.

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!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.