Hello,
I have a list of values with the following columns Date, Sotck_Name and stock_Value.

Date (yyyy/mm/dd), Stock_Name, Stock_Value
2012/02/01; Index1, 2
2012/02/01; A; 1
2012/02/01, B, 2
2012/02/01, C, 3
2012/02/02; Index1, 3
2012/02/02, A, 2
2012/02/02, C, 3
2012/02/08; Index1, 3
2012/02/08, A, 2
2012/02/08, B, 3
2012/02/08, C, 3
2012/02/10; Index1, 4


I would like to calculate the forecast for each stock (A, B and C) using as the reference Index1.

The formula of Forecast is as follows: FORECAST (x, ref_x, ref_y), and
x - the current value of the Index1 from the date of 2012/02/10
ref_x – the values of Index1 from 2012/02/01 to current date
ref_y – the values of stock in analysis from 2012/02/01 until the last date charged

Thus the calculation of the Forecast for the stock A, would be = FORECAST (4, <2,3,3,4>, <1,2,2>), and
<2,3,3,4> - the values of the Index1 to date
<1,2,2> - the values of the stock A to date

My doubt is how to define the values of ref_x and ref_y therefore can not only select the Stock_Value column, so I will include values relating to the Index1 and the remaining stocks.

Any suggestions?