Forum Discussion
List.generate syntax error
Hi MiraAbel ,
not sure I understand the requirement correctly, but please try replacing the 1 by b like so:
= Table.AddColumn(#"Changed Type", "Cash Flow Years", (x) => List.Generate( () =>
[ a = x[Delivery Date], b=0 ],
each [b] <= x[ Years],
each [b = [b]+1 , a = Date.AddYears( [a], b )], each [a] ))
- MiraAbel3 years agoFrequent Visitor
I am afraid, if I replace "1" with "B" the list skips progressively .... oouch!
I am trying to get the following list for the record in [Delivery Date]= #date(2024, 3, 31) it should start from #date(2025, 3, 31)..
Many thanks for your time
Mira - MiraAbel3 years agoFrequent Visitor
The solution to my question is as follows:
= Table.AddColumn(#"Changed Types", "Dates", (x) => List.Generate( () =>
[ a = Date.AddYears( x[Delivery Date], 1 ), b=0 ],
each [b] <= x[Years],
each [b = [b]+1 , a = Date.AddYears( [a], 1 )], each [a] ))
It answers a bigger question for me that List.Generate in fact can start from a function (formula!) rather than just a starting value (text, or number etc)