Showing results for 
Search instead for 
Did you mean: 

Simple Linear Regression

mski_dev New Member
New Member

Re: Simple Linear Regression

Daniil, (or anyone else knowledgeable)

Many thanks for this but I am struggling a little with adapting it to my needs, as I am still quite new to DAX.

I am trying to create a sales prediction model and want to use the linear trend from just the last 12 months, I believe your current code will give me the linear regression from all of the data.

How do a go about just using the last 12 months of data to feed the regression.


Many thanks for anyone that might be able to help,


Servus Frequent Visitor
Frequent Visitor

Re: Simple Linear Regression

I reckon DAX might be cumbersome for this. You can consider installing python in Power BI to generate a linear model for your analysis. @jwjwjwjwjw 

Upendoon Occasional Visitor
Occasional Visitor

Re: Simple Linear Regression

Hi @Daniil,


I'm trying to find the slope of a graph comparing 2 pollution datasets. I altered your measure to do this. The measure works well until it comes to summing the X^2 and XY values. The multiplication doesn't work and this affects the slope calculation.


What could be causing this problem?


PS: I'm very inexperienced with Power BI, so forgive me if this is a stupid question related to SUM and SUMX.