Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more
Hello. I have what seems like should be an easy solution. We have some reports that are already created and published that we want to use Python to create control charts with. Everything I can find on the web - so far - references connections to outside sources. How do I get Python to read the existing data model in Power BI?
Hi @boyddt_mn ,
The following link shares about using Python scripts to import a data source, clean the data, analyze the data and create visualizations with it:
Solved: PYTHON INTEGRATION WITH POWER BI - IMPORTING EXCEL... - Microsoft Fabric Community
You can use Python scripts to manipulate existing data. This can be done in the "Transform" tab under the Edit queries section. There is an option to select "Run Python Script". Once you select this option a dialog box will open and you can write the Python script you want.
Use Python in Power BI Power Query Editor - Power BI | Microsoft Learn
This is the related document, you can view this content:
pandas - How to read Data From Power BI Dataset to Python - Stack Overflow
Solved: How to read Data From Power BI Dataset to Python - Microsoft Fabric Community
Run Python scripts in Power BI Desktop - Power BI | Microsoft Learn
Best Regards,
Liu Yang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Thank you for your response but these don't three of the five links don't reference connecting to a local data model. The second and third links suggest using dataset to connect to the local model but Power BI returns "NameError: name 'dataset' is not defined". I've tried a couple if iterations but haven't had much luck. Here is my code:
import pandas as pd
import seaborn as sb
import matplotlib.pyplot as plt
CAPA_Main = dataset[dataset["CAPA_Main"]]
plt.bar(CAPA_Main.capa_main.created_date, CAPA_Main.capa_main.cap_number)
plt.xlabel("Date")
plt.ylabel("NR Count")
plt.show
and here is a screenshot of my data model
Any help is appreciated.
The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!
| User | Count |
|---|---|
| 3 | |
| 2 | |
| 2 | |
| 1 | |
| 1 |
| User | Count |
|---|---|
| 10 | |
| 6 | |
| 4 | |
| 4 | |
| 3 |