沿用4楼的句子,加一个年的分组判断:(以后最好上附件,这样别人都直接用你的文件回复给你了)
let
源 = Excel.CurrentWorkbook(){[Name="表1"]}[Content],
更改的类型 = Table.TransformColumnTypes(源,{{"季度", type text}, {"累计金额", Int64.Type}}),
年度提取 = Table.AddColumn(更改的类型, "年度", each Text.Start([季度],4)),
分年索引 = Table.Group(年度提取, {"年度"}, {"a",each [a = Table.AddIndexColumn(_,"索引",0),
b = Table.AddColumn(a,"单季金额",each if [索引]=0 then [累计金额] else [累计金额]-a[累计金额]{[索引]-1})]}),
展开 = Table.ExpandTableColumn(分年索引, "a", {"季度", "累计金额", "索引", "单季金额"}, {"季度", "累计金额", "索引", "单季金额"}),
提取 = Table.SelectColumns(展开,{"季度", "累计金额", "单季金额"})
in
提取
|