Hi @Djpejsen
(Kind reminder: you're not supposed to write to me until I responded once)
Thanks for the quality of the sample & the calculations. The approach is similar to your previous case but less complex :)). Assuming data in Table1:
let
Source = Table1,
AddedIndex = Table.AddIndexColumn(Source, "ID", 0, 1),
GenInterestAndBalance = List.Generate(()=>
[i = 0,
Interest = AddedIndex[Cashflow]{i} * AddedIndex[#"Interest %"]{i},
Balance = AddedIndex[Cashflow]{i} + (1*AddedIndex[#"Interest %"]{i})
],
each [i] < Table.RowCount(AddedIndex),
each
[
i = [i] + 1,
Interest = AddedIndex[#"Interest %"]{i} * [Balance],
Balance = ([Balance]*AddedIndex[#"Interest %"]{i})
+ [Balance] + AddedIndex[Investment]{i}
],
each [ [Interest], [Balance] ]
),
ToTable = Table.FromColumns(
Table.ToColumns(AddedIndex) &
Table.ToColumns(Table.FromRecords(GenInterestAndBalance,
type table [Interest=number, Balance=number])
),
Table.ColumnNames(AddedIndex) & {"Interest $", "Balance"}
),
RemovedIndex = Table.RemoveColumns(ToTable,{"ID"})
in
RemovedIndex
If you want to turn it as a function let me know. It probably makes sense to buffer the AddedIndex table
Corresponding sample avail. here
Cheers