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
Hi all,
I'm trying to use Power BI and Python to get a multivariate regression model built in Power BI Desktop. Using Python, I've imported the following packages to get started: pandas, numpy, matplotlib, statsmodels
Let's assume two independent variables (X1 and X2) and 1 dependent variable Y.
When using Python, I've used this script:
import pandas as pd
import numpy as np
import matplotlib as plt
import statsmodels.api as sm
dataframe = pandas.DataFrame["X1 data", "X2 data", "Y data"]
X1 = dataframe["Name of X1 variable"]
X2 = dataframe["Name of X2 variable"]
Y = dataframe["Name of Y variable"]
model = sm.OLS(Y, X)
results = model.fit()
print(results.summary())
Which creates the image <here> , but the command doesn't work in Power BI. Does anyone have any ideas?
Hi @Anonymous ,
Have you defined values to your variable?What is the error returned?
Here is the reference you can refer to.
See, if this can help you out
https://towardsdatascience.com/using-python-in-power-bi-ee95a6b71443
https://www.youtube.com/watch?v=EmALxO7V7y0
https://www.powerobjects.com/blog/2018/10/01/python-starter-power-bi-desktop/
https://powerbi.microsoft.com/en-us/blog/power-bi-desktop-august-2018-feature-summary/#python
First thing I would check is if all of those packages are supported in Power BI. Also, define "does not work", do you get an error, blank screen, Power BI crashes and burns?
The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!
| User | Count |
|---|---|
| 61 | |
| 44 | |
| 41 | |
| 36 | |
| 21 |
| User | Count |
|---|---|
| 176 | |
| 120 | |
| 106 | |
| 77 | |
| 52 |