I want to calculate rolling average of the previous 3 months.
I was going to do this using windowed lag functions
(
(LAG(SUM(`Sales Amount`),1) OVER (ORDER BY `YEARMONTH`)) +
(LAG(SUM(`Sales Amount`),2) OVER (ORDER BY `YEARMONTH`)) +
(LAG(SUM(`Sales Amount`),3) OVER (ORDER BY `YEARMONTH`))
)/ 3
Each Lag works individually but any time I try to do any computation between them the card breaks and throws the error:
An issue has occurred during processing. We are unable to complete the request at this time.
Any idea of how I can get around this? Or is this no longer possible? I feel like I have done this in the past.