Forum Discussion
cousinitt13
3 years agoHelper I
Linear regression with multiple values in one column
Hello,
I've managed to create linear regression of my table - BUT - I have to filter the results cause of the table structure.
See the table below, I'd like to get the linear regression of width, of height and of range
my table
| ID | VARIABLE | RESULT |
1 | width | 5 |
2 | height | 6 |
3 | range | 7 |
4 | width | 8 |
5 | range | 9 |
6 | height | 7 |
LinearRegression =
VAR linreg =
LINESTX (
ALL ( 'Date'[ShiftDate] ),
'Date'[ShiftDate],
AVERAGE(Quality_DEAT[Result])
)
VAR slope = SELECTCOLUMNS ( linreg, [Slope1] )
VAR intercept = SELECTCOLUMNS ( linreg, [Intercept] )
VAR x = SELECTEDVALUE ( Quality_DEAT[Result] )
VAR y = x * slope + intercept
RETURN y
br
1 Reply
- AnonymousNot applicable
Hi cousinitt13 ,
Please have a try.
LinearRegressionWidth = VAR linreg = LINESTX ( FILTER ( ALL ( 'Date'[ShiftDate] ), Quality_DEAT[VARIABLE] = "width" ), 'Date'[ShiftDate], AVERAGE ( Quality_DEAT[Result] ) ) VAR slope = SELECTCOLUMNS ( linreg, [Slope1] ) VAR intercept = SELECTCOLUMNS ( linreg, [Intercept] ) VAR x = SELECTEDVALUE ( Quality_DEAT[Result] ) VAR y = x * slope + intercept RETURN yHow to Get Your Question Answered Quickly
If it does not help, please provide more details with your desired output and pbix file without privacy information (or some sample data) .
Best Regards
Community Support Team _ RongtieIf this post helps, then please consider Accept it as the solution to help the other members find it more quickly.