• mark.wojciechowicz@gmail.com - Monday, February 8, 2010 8:33 PM

    Comments posted to this topic are about the item Forecasting with SQL

    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