Hi Mark, I believe there is an error in your code. When looping and using y = a+bx to forecast yi you are using x(i-1) then adding 1 (i.e. your parenthesis are off) instead of using xi:
MAX(A) + (MAX(B) * MAX(Forecastkey) + 1), -- Trendline
(MAX(A) + (MAX(B) * MAX(Forecastkey) + 1))*
(SELECT ...
Should be:
MAX(A) + (MAX(B) * (MAX(Forecastkey) + 1)), -- Trendline
(MAX(A) + (MAX(B) * (MAX(Forecastkey) + 1)))*
(SELECT ...
Outside of this, thanks for the very useful code! Feel free to contact me direct if you'd like to discuss.
James
James,
Thanks for reviewing this and finding the bug. I have submitted a correction to the article and attachment.
m