Решение задачи:
Запрос
let
Source = Table1,
#"Replaced Value" = Table.ReplaceValue(Source,null,0,Replacer.ReplaceValue,{"Поступление Эскроу", "Кредит"}),
BuffValuesEscrow = List.Buffer ( #"Replaced Value"[Поступление Эскроу] ),
BuffValuesCredit = List.Buffer ( #"Replaced Value"[Кредит] ),
RunningTotal =
List.Generate (
() => [ RT_Credit = BuffValuesCredit{0}, RT_Escrow = BuffValuesEscrow{0}, RowIndex = 0 ],
each [RowIndex] < List.Count(BuffValuesCredit),
each [RT_Escrow = List.Sum({[RT_Escrow], BuffValuesEscrow{[RowIndex] + 1}}), RT_Credit = List.Sum( { [RT_Credit], BuffValuesCredit{[RowIndex]+1} + [RT_Credit] * Rate([RT_Escrow] / [RT_Credit]) } ), RowIndex = [RowIndex] + 1 ],
each [RT_Credit] ),
#"Combined Table + RT" =
Table.FromColumns(
Table.ToColumns( #"Replaced Value" )
& { Value.ReplaceType( RunningTotal, type {Double.Type}) } ,
Table.ColumnNames( #"Replaced Value" ) & {"Накопленный кредит + Проценты"} )
in
#"Combined Table + RT"
Дополнительная функция Rate
(Z) => if Z <= 0.2
then 0.05
else if Z <= 0.8
then 0.025
else if Z <= 1
then 0.01
else 0
Запрос
let
Source = Table1,
#"Replaced Value" = Table.ReplaceValue(Source,null,0,Replacer.ReplaceValue,{"Поступление Эскроу", "Кредит"}),
BuffValuesEscrow = List.Buffer ( #"Replaced Value"[Поступление Эскроу] ),
BuffValuesCredit = List.Buffer ( #"Replaced Value"[Кредит] ),
RunningTotal =
List.Generate (
() => [ RT_Credit = BuffValuesCredit{0}, RT_Escrow = BuffValuesEscrow{0}, RowIndex = 0 ],
each [RowIndex] < List.Count(BuffValuesCredit),
each [RT_Escrow = List.Sum({[RT_Escrow], BuffValuesEscrow{[RowIndex] + 1}}), RT_Credit = List.Sum( { [RT_Credit], BuffValuesCredit{[RowIndex]+1} + [RT_Credit] * Rate([RT_Escrow] / [RT_Credit]) } ), RowIndex = [RowIndex] + 1 ],
each [RT_Credit] ),
#"Combined Table + RT" =
Table.FromColumns(
Table.ToColumns( #"Replaced Value" )
& { Value.ReplaceType( RunningTotal, type {Double.Type}) } ,
Table.ColumnNames( #"Replaced Value" ) & {"Накопленный кредит + Проценты"} )
in
#"Combined Table + RT"
Дополнительная функция Rate
(Z) => if Z <= 0.2
then 0.05
else if Z <= 0.8
then 0.025
else if Z <= 1
then 0.01
else 0
Изменено: - 02.12.2024 14:26:49