简体   繁体   English

来自单元格值的 Power Query 文件路径

[英]Power Query file path from cell value

I have, in my excel workbook, a Table called ResultsTable, in that table there is a file path我的 excel 工作簿中有一个名为 ResultsTable 的表,该表中有一个文件路径在此处输入图像描述

C:\Users\XXXX\OneDrive - WORK\Digital Soil\Data\Results C:\Users\XXXX\OneDrive - WORK\Digital Soil\Data\Results

I have Query that should get all excel files from the folder and transform the data into something usefull looking like this:我有查询应该从文件夹中获取所有 excel 文件并将数据转换为有用的东西,如下所示:

let
    Source = Folder.Files("ResultsTable"),
    #"Filtered Hidden Files1" = Table.SelectRows(Source, each [Attributes]?[Hidden]? <> true),
    #"Invoke Custom Function1" = Table.AddColumn(#"Filtered Hidden Files1", "Transform File from Analyseresultater", each #"Transform File from Analyseresultater"([Content])),
    #"Renamed Columns1" = Table.RenameColumns(#"Invoke Custom Function1", {"Name", "Source.Name"}),
    #"Removed Other Columns1" = Table.SelectColumns(#"Renamed Columns1", {"Source.Name", "Transform File from Analyseresultater"}),
    #"Expanded Table Column1" = Table.ExpandTableColumn(#"Removed Other Columns1", "Transform File from Analyseresultater", Table.ColumnNames(#"Transform File from Analyseresultater"(#"Sample File"))),
    #"Removed Other Columns" = Table.SelectColumns(#"Expanded Table Column1",{"Key", "Attribute", "Value"})
in
    #"Removed Other Columns"

But I get the error但我得到了错误

DataFormat.Error: The supplied folder path must be a valid absolute path. DataFormat.Error:提供的文件夹路径必须是有效的绝对路径。 Details: ResultsTable详细信息:结果表

I hope someone can help me get through this error:)我希望有人可以帮助我解决这个错误:)

EDIT: Added screenshot of how my sheet with tables are set up编辑:添加了如何设置我的表格的屏幕截图

You can fix the code like,您可以修复代码,例如,

let
    FilePath = Excel.CurrentWorkbook(){[Name="ResultsTable"]}[Content][Path to results]{0},
    Source = Folder.Files(FilePath),

In the original code, Folder.Files() was receiving the literal text "ResultsTable", not the cell value in ResultsTable.在原始代码中, Folder.Files()接收的是文字文本“ResultsTable”,而不是 ResultsTable 中的单元格值。 You need to first pick the cell value with Excel.CurrentWorkbook() , and then pass it to Folder.Files() .您需要首先使用Excel.CurrentWorkbook()选择单元格值,然后将其传递给Folder.Files()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM