Forum Discussion
Magnus Vegem Dahle
Jun 20, 2018Brass Contributor
Power Query Source from Relative Paths
Hi All, I am making an analysis tool that uses two Excel file sources via Power Query. The tool work well, but as soon as the file and source files are moved to another location it stops working ...
- Jun 20, 2018
Hi Magnus,
You may find the current file path putting in any cell of your workbook the formula
=LEFT(CELL("filename",$A$1),FIND("[",CELL("filename",$A$1),1)-1)
name this cell somehow, let say "FilePath" and generate absolute path in query like
<prev step> FilePath = Excel.CurrentWorkbook(){[Name="FilePath"]}[Content]{0}[Column1], FullPathToFile1 = FilePath & "Name1.xlsx" <next step>
SergeiBaklan
Jun 20, 2018MVP
Hi Magnus,
You may find the current file path putting in any cell of your workbook the formula
=LEFT(CELL("filename",$A$1),FIND("[",CELL("filename",$A$1),1)-1)
name this cell somehow, let say "FilePath" and generate absolute path in query like
<prev step> FilePath = Excel.CurrentWorkbook(){[Name="FilePath"]}[Content]{0}[Column1], FullPathToFile1 = FilePath & "Name1.xlsx" <next step>
JeffersonValim
Feb 02, 2023Copper Contributor
Maybe this vba code helps:
Function FilePath()
Application.Volatile
FilePath = Application.ActiveWorkbook.Path & "\base.xlsx"
End Function
- SergeiBaklanFeb 13, 2023MVP
Actually the question is how to pass that into Power Query, doesn't matter how filepath was generated.