Forum Discussion
avachris
4 years agoFrequent Visitor
Recursive Function Forecasting
Hi there - I have a list of portfolios that I'd like to forecast through time. I also have a seperate table which outlines the quarter over quarter growth rate. I think the right soluti...
- 4 years ago
avachris
4 years agoFrequent Visitor
Hi there - For folks looking at this, here is the commented code as far as I can figure it out.
let
PT = Table.ToRows(Portfolio),
FT = Table.ToRows(Forecast)
in #table ({"Porfolio"}&Table.ColumnNames(Forecast)&{"Forecast Value"},
List.TransformMany(PT, each FT,
(x,y)=> {x{0}}&y& // starts building the table with the first column of portfolio and column from forecast
{List.Accumulate // start the accumulate loop
(List.Select(FT,each _{3}<=y{3} and _{0}=y{0} // filters a table for where the scenario names match and where the forecast rows are lessthan or equal to current forecast period
),x{1}, // seeds the value with the jump off of the portfolio
(x,y) => x*(1+y{1}/100)+y{2})})) // applies the assumptions from the forecast table
wdx223_Daniel a couple of questions for you:
In the following step is there a way to access the original Portfolio table to get additional columns, for example it would be helpful to grab the portfolio maturity date for the portfolio table. If not, was thinking I could use your method to create a permutation of the forecast table and portfolio table (essentially making the Y table bigger with all relevant columns)
(x,y) => x*(1+y{1}/100)+y{2})})) // applies the assumptions from the forecast table
Also is the list accumulate limited to only 1 value, what if I wanted to track two values through time so that I could then compare those two values in a future period?