Linear Regression with Power BI DAX Formulas

Calculated Columns with DAX

Math FormulaDAX Formula
xsq =
Salary_Data[Years of Experience]^2
xyxy =
Salary_Data[Years of Experience]*Salary_Data[Salary]
Measures with DAX
Math FormulaDAX Formula
nn =
COUNTROWS(Salary_Data)
∑xy xysum =
SUM(Salary_Data[xy])
∑xxsum =
SUM(Salary_Data[Years of Experience])
∑yysum =
SUM(Salary_Data[Salary])
∑x²xsqrsum =
SUM(Salary_Data[xsq])
(n(∑xy)-(∑x)(∑y))/(n(∑x²)-(∑x)²)m (Slope) =
DIVIDE(
    [n]*[xysum]-[Xsum]*[Ysum],
    [n]*[xsqrsum]-[Xsum]^2,
    0
)
((∑y)(∑x^2)-(∑x)(∑xy))/(n(∑x²)-(∑x)²)b (Intercept) =
DIVIDE(     [ysum]*[xsqrsum]-[Xsum]*[xysum],     [n]*[xsqrsum]-[Xsum]^2,
    0
)

Final Math Formula

Math FormulaDAX Formula
y = mx + bPredicted Salary =
([m (Slope)]*
‘x (Years of Experience)'[x (Years of Experience)Value]+
[b (Intercept)])
Scroll to Top