let
源 = Excel.CurrentWorkbook(){[Name="表1"]}[Content],
降级的标题 = Table.DemoteHeaders(源),
更改的类型 = Table.TransformColumnTypes(降级的标题,{{"Column1", type text}, {"Column2", type text}, {"Column3", type text}, {"Column4", type text}, {"Column5", type any}, {"Column6", type any}, {"Column7", type any}, {"Column8", type any}, {"Column9", type any}, {"Column10", type any}}),
已添加自定义 = Table.AddColumn(更改的类型, "自定义", each _),
删除的其他列 = Table.SelectColumns(已添加自定义,{"自定义"}),
已添加自定义1 = Table.AddColumn(删除的其他列, "自定义.1", each {1..3}),
aa = Table.ExpandListColumn(已添加自定义1, "自定义.1"),
已添加自定义2 = Table.AddColumn(aa, "自定义.2", each if [自定义.1]=1 then aa[自定义]{0} else if [自定义.1]=2 then [自定义] else null),
删除的其他列1 = Table.SelectColumns(已添加自定义2,{"自定义.2"}),
#"展开的“自定义.2”" = Table.ExpandRecordColumn(删除的其他列1, "自定义.2", {"Column1", "Column2", "Column3", "Column4", "Column5", "Column6", "Column7", "Column8", "Column9", "Column10"}, {"Column1", "Column2", "Column3", "Column4", "Column5", "Column6", "Column7", "Column8", "Column9", "Column10"}),
删除的顶端行 = Table.Skip(#"展开的“自定义.2”",3),
提升的标题 = Table.PromoteHeaders(删除的顶端行, [PromoteAllScalars=true]),
更改的类型1 = Table.TransformColumnTypes(提升的标题,{{"工号", type text}, {"部门", type text}, {"姓名", type text}, {"职务", type text}, {"底薪", type any}, {"平时加班", type any}, {"节假日加班", type any}, {"应发金额", type any}, {"扣除", type any}, {"实发金额", type any}})
in
更改的类型1
补充内容 (2020-11-24 17:31):
突然看到自己写的丑代码,不忍再看下去了 |