想要整理一个乱七八糟的表,如下图
先设定此表
====代码====
查询:标题
let
源 =Excel.Workbook(File.Contents("C:UsersAdministratorDesktopPositionOf.xlsx"),null, true),
标题_Sheet = 源{[Item="标题",Kind="Sheet"]}[Data],
更改的类型 = Table.TransformColumnTypes(标题_Sheet,{{"Column1",type text}, {"Column2", type text}}),
提升的标题 = Table.PromoteHeaders(更改的类型,[PromoteAllScalars=true]),
更改的类型1 = Table.TransformColumnTypes(提升的标题,{{"原列名", type text}, {"新列名", typetext}}),
转置表 =Table.Transpose(更改的类型1),
自定义1 = Table.ToColumns(转置表)
in
自定义1
查询:
let
源 =Excel.Workbook(File.Contents("C:UsersAdministratorDesktopPositionOf.xlsx"),null, true),
Sheet2_Sheet = 源{[Item="Sheet2",Kind="Sheet"]}[Data],
删除的顶端行= Table.Skip(Sheet2_Sheet,4),
删除的底部行 = Table.RemoveLastN(删除的顶端行,Table.RowCount(删除的顶端行)-List.PositionOf(删除的顶端行[Column1],"合计")),
删除后面的空 = Table.SelectRows(删除的底部行,each[Column1]<>null),
自定义2 = Table.RenameColumns(删除后面的空,标题)
in
自定义2
=====完成=====