Getting syntax error to calculate MOM change

Options

Can anyone help me what syntax error is there in this beast mode calculation?

CASE
WHEN LAG(Weighted Average, 1) OVER (ORDER BY Sort: Month Number) IS NOT NULL THEN
(Weighted Average - LAG(Weighted Average, 1) OVER (ORDER BY Sort: Month Number))
/
NULLIF(LAG(Weighted Average, 1) OVER (ORDER BY Sort: Month Number), 0)
ELSE
NULL
END

Tagged:

Best Answer

  • Chris_Wolman
    Chris_Wolman Contributor
    Answer ✓
    Options

    Hello @agolla2 ,

    I believe the issue is with your order by clause. I would expect it to be (ORDER BY Month Number).

    (ORDER BY Month Number ASC) for ascending or (ORDER BY Month Number DESC) for descending.

    Chris

    ** Was this post helpful? Click Agree 😀, Like 👍️, or Awesome ❤️ below **
    ** Did this solve your problem? Accept it as a solution! ✔️**

Answers

  • Chris_Wolman
    Chris_Wolman Contributor
    Answer ✓
    Options

    Hello @agolla2 ,

    I believe the issue is with your order by clause. I would expect it to be (ORDER BY Month Number).

    (ORDER BY Month Number ASC) for ascending or (ORDER BY Month Number DESC) for descending.

    Chris

    ** Was this post helpful? Click Agree 😀, Like 👍️, or Awesome ❤️ below **
    ** Did this solve your problem? Accept it as a solution! ✔️**