Forum Discussion

cousinitt13's avatar
cousinitt13
Helper I
3 years ago

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

IDVARIABLERESULT

1

width5

2

height6

3

range7

4

width8

5

range9

6

height7

 

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

  • Anonymous's avatar
    Anonymous
    Not 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
        y
    

    How 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 _ Rongtie

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.