Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
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?
Check out the July 2025 Power BI update to learn about new features.
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
User | Count |
---|---|
69 | |
68 | |
40 | |
29 | |
26 |
User | Count |
---|---|
87 | |
49 | |
45 | |
38 | |
37 |