|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
还是要按日期分组,然后直接在分组后的Table上用Table.ReplaceValue把计算结果替换进去即可,- let
- Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("rZTRSgJBFIZfJfZaZc45u7riA3TXC4hPsrgYJEp4IWQRURdBXgSZN2ZW4NM4g71FM7oV7MzONjYLOywL/8fMOWe+djtAhsDfFiBuh0ElOGahXBmoBVtVFrcA5TfU+KDHh4/idC4mSzGZy39Bp1KQVomEUcoa3V0WfpK8P7UmSS4n8j3KHpmV6dm1mKw3qxl/eP68WG7vRzkeMFaMDA1I5OPRZnXD1z1xN83B0AaLDDDaLl7F09plT3UDJhTnl9uXMxdMw4CJeH+5+bhywcS7djVTgH278Ds854N3a7ua2gZQtstQ24xkqy0wAyx3mgxDNgwYMKRG6LdFGaZpw6gZriZAKUTdVgL1FOJ9dSjb0t/vA+hTTbJMeYzaFZQVSZ9mkv0yobAMpc8yGQ6nUFSG0udZoQruGJTMI+hjTbWwiIZltNhAi4popNPwX2LEg8WIfsRoOcsBZrTQnNRo4Ti50cJxkqOF42JH9GlH9GNH9GNH9GhH9GdH9GdH9GdH9GpH9GpH9GDHzhc=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [日期 = _t, 报表名称 = _t, 项目代码 = _t, 项目计算 = _t, 项目名称 = _t, 金额 = _t]),
- #"Changed Type" = Table.TransformColumnTypes(Source,{{"日期", type text}, {"报表名称", type text}, {"项目代码", Int64.Type}, {"项目计算", type text}, {"项目名称", type text}, {"金额", Int64.Type}}),
- #"Grouped Rows" = Table.Group(#"Changed Type", {"日期"}, {{"ar", each let amt = [金额]
- in Table.ReplaceValue(
- _,
- null,
- each Record.Field(
- [
- #"1" = #"2" + #"12" - #"8",
- #"2" = List.Sum(List.Range(amt,2,5)),
- #"8" = List.Sum(List.Range(amt,8,3)),
- #"12" = List.Sum(List.Range(amt,15,3)) - List.Sum(List.Range(amt,12,3))
- ],
- Text.From([项目代码])
- ),
- Replacer.ReplaceValue,
- {"金额"}
- )}}),
- #"Expanded ar" = Table.ExpandTableColumn(Table.RemoveColumns(#"Grouped Rows",{"日期"}), "ar", {"日期", "报表名称", "项目代码", "项目计算", "项目名称", "金额"}, {"日期", "报表名称", "项目代码", "项目计算", "项目名称", "金额"})
- in
- #"Expanded ar"
复制代码
|
|