Don't miss your chance to take the Fabric Data Engineer (DP-600) exam for FREE! Find out how by attending the DP-600 session on April 23rd (pacific time), live or on-demand.
Learn moreNext up in the FabCon + SQLCon recap series: The roadmap for Microsoft SQL and Maximizing Developer experiences in Fabric. All sessions are available on-demand after the live show. 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.
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.
Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.
| User | Count |
|---|---|
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |
| User | Count |
|---|---|
| 4 | |
| 4 | |
| 3 | |
| 3 | |
| 2 |