kopite833's avatar
kopite833
Frequent Visitor
3 years ago
Status:
Needs Info

LINESTX bugs

Using Power BI Report Server, the following issues exist for LINESTX...

 

LINESTX does not report values in row context, so variance to Y-Axis values cannot be calculated...

 

KnownX values must be placed in the X-Axis field well to display and evaluate the line...

 

 

Polynomial regression does not appear to work...

 

Order3PolyRegression =
VAR Line =
    LINESTX (
        ALLSELECTED ( Trade[KnownX] ),
        [KnownY],
        [KnownX],
        [knownY],
        [KnownX] ^ 2,
        [knownY],
        [KnownX] ^ 3
    )
VAR Slope1 =
    SELECTCOLUMNS ( Line, [Slope1] )
VAR Slope2 =
    SELECTCOLUMNS ( Line, [Slope2] )
VAR Slope3 =
    SELECTCOLUMNS ( Line, [Slope3] )
VAR Intercept =
    SELECTCOLUMNS ( Line, [Intercept] )
VAR x =
    SELECTEDVALUE ( Trade[KnownX] )
VAR Result = ( x ^ 3 * Slope3 ) + ( x ^ 2 * Slope2 ) + ( x * Slope1 ) + Intercept
RETURN
    Result

 

 

 

3 Comments

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi  kopite833 ,

     

    Can you provide detailed version information so we can reproduce the issue? We'll get back to the product team as soon as it's acknowledged as an issue!
    Thanks in advance!

     

    Best regards.
    Community Support Team_Caitlyn

  • kopite833's avatar
    kopite833
    Frequent Visitor

    Found work around for the 1st 2 notes in my original post, but the polynomial regression formula I provided doesn't work. The formula I provided should produce a seasonal trend line with 2 curves (dark blue), more closely aligned to the actuals (light blue). 

  • kopite833's avatar
    kopite833
    Frequent Visitor

    Suggest a better implementation of LINESTX would be...

     

    LINESTX ( <table>, <expressionY>, <expressionX>, <const>, <regressiontype>, <ouput>)

     

    Where <regressiontype> and <output> provide options user chooses, as follows...

     

    Regression type: linear, polynomial_2, polynomial_N (up to 6, like Excel), etc

     

    Output: slope(s), intercept, standarderrorslope(s), line values, other stats, etc