Power BI is turning 10, and we’re marking the occasion with a special community challenge. Use your creativity to tell a story, uncover trends, or highlight something unexpected.
Get startedJoin us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.
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.
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
9 | |
8 | |
4 | |
2 | |
2 |
User | Count |
---|---|
4 | |
3 | |
3 | |
3 | |
2 |