How can I reference a cell's value in PowerQuery

前端 未结 1 2045
眼角桃花
眼角桃花 2020-11-27 15:40

I\'m having multiple PowerQuery queries that I would like to feed the value of a cell in my Excel file. In this particular case, the full path to the sourcefile name.

<
相关标签:
1条回答
  • 2020-11-27 16:34

    This can be achieved using a named range and a custom function in PowerQuery:

    1. Name the cell you need to refer (type in a name into the file left of the formula bar) - e.g. SourceFile
    2. Insert a new blank PowerQuery query (PowerQuery ribbon -> From other sources)
    3. In the PowerQuery editor, go to View -> Advanced Editor and paste the following code;
    (rangeName) => 
        Excel.CurrentWorkbook(){[Name=rangeName]}[Content]{0}[Column1]
    
    1. Name the query to GetValue (Name property in the Query settings pane on the right)

    Now you can access the named cell in your queries, using GetValue(cellName) - e.g.

    = Excel.Workbook(File.Contents(GetValue("SourceFile")))
    
    0 讨论(0)
提交回复
热议问题