Forum Discussion

Ethanhunt123's avatar
Ethanhunt123
Icon for Helper IV rankHelper IV
2 years ago
Solved

LINESTX with slicer

Hello,    I am trying to calculate trends using slope and intercept    I am using the following DAX, which is functioning well. However, the issue arises when I have a slicer on the order date. I...
  • BeaBF's avatar
    2 years ago

    Ethanhunt123 Hi! Try with:

    Revenue trend =
    VAR line =
    LINESTX (
    ALLSELECTED('Sales order line fact'[Order date]), -- This respects the slicer
    [Total revenue trend],
    'Sales order line fact'[Order date]
    )
    VAR slope = SELECTCOLUMNS(line, [Slope1])
    VAR intercept = SELECTCOLUMNS(line, [Intercept])
    VAR x = SELECTEDVALUE('Sales order line fact'[Order date])
    VAR y = x * slope + intercept
    RETURN y

     

    BBF