我使用内联PowerQuery来自动执行每周报告。由于我是电源查询新手,因此我跟进了此tutorial并尝试添加自定义列,以便我可以使用它来查看一周一周的改进,事情是添加的列未命名&#34 ;周"但它被称为文件的名称。从这个webpage开始,第二个参数是列名。我找不到为什么列名是文件名而不是名称"周"。
let ExcelFile = (FilePath, FileName) =>
let
Source = Folder.Files(FilePath),
File = Source{[#"Folder Path"=FilePath,Name=FileName]}[Content],
ImportedExcel = Excel.Workbook(File),
Sheet1 = ImportedExcel{[Name="Page1_1"]}[Data],
TableWithWeek = Table.AddColumn(Sheet1,"Week", each FileName),
TableWithoutHeader = Table.Skip(TableWithWeek,3),
FirstRowAsHeader = Table.PromoteHeaders(TableWithoutHeader)
in
FirstRowAsHeader
in
ExcelFile
答案 0 :(得分:0)
这个电话:
FirstRowAsHeader = Table.PromoteHeaders(TableWithoutHeader)
将使用第一行中的值替换您的列名。从第"周"下的第一个值开始是文件名,然后您的表将使用该文件名作为列名。
您可以在使用PromoteHeaders后添加自定义列来解决此问题:
let ExcelFile = (FilePath, FileName) =>
let
Source = Folder.Files(FilePath),
File = Source{[#"Folder Path"=FilePath,Name=FileName]}[Content],
ImportedExcel = Excel.Workbook(File),
Sheet1 = ImportedExcel{[Name="Page1_1"]}[Data],
TableWithoutHeader = Table.Skip(Sheet1, 3),
FirstRowAsHeader = Table.PromoteHeaders(TableWithoutHeader),
TableWithWeek = Table.AddColumn(FirstRowAsHeader,"Week", each FileName),
in
TableWithWeek
in
ExcelFile