Jul 19 2021 01:29 PM
Let me start by saying that I have read the posts about converting from an Absolute path to a Relative path in PowerQuery (primarily https://techcommunity.microsoft.com/t5/excel/power-query-source-from-relative-paths/m-p/206150) which was very helpful. I've also read through other posts by @Sergei Baklan which were helpful identifying my issues. The problem is that some of my users may be using OneDrive, others OneDrive for Business, and still others not using OneDrive at all.
When I follow the directions in the above quoted link and then send the file to someone using OneDrive, they cannot refresh the Query. The error message says there is a Data Format Error and that the supplied file path is invalid because it is a hyperlink. Which leads me to two questions:
I would imagine it would be some form of an If then statement:
If filepath is a Sharepoint link
Use this address for the file
Else
Follow the directions in the above post to get the filepath.
I'm just not familiar enough with the language to even begin to parse that out.
Any help would be greatly appreciated.
Thanks!
Christopher
Aug 31 2023 05:06 PM
I used the CELL("filename",$A$1) function above to obtain my file path. This returned a relative path with forward slashes. Power Query error said that it needs to be an absolute path, so I replaced the forward slashes with back slashes. I am trying to grab my data from a folder with multiple files and the source function keeps failing with the following code:
let
FilePath = Excel.CurrentWorkbook(){[Name="MyFilePath"]}[Content]{0}[Column1],
FullPathSales = FilePath & "Data Files\Sale Detail",
Source = Folder.Files(FullPathSales), ((folder path must be valid absolute path))
I have tried some of the other functions for the Source,
Excel.Workbook(Web.Contents(FullPathSales), null, true) ((Format Error: Host Name cannot Parse)) & Excel.Workbook(File.Contents(FullPathSales), null, true) ((Must be valid absolute path)).
The FullPathSales result is:
https:\\.....my.sharepoint.com\.....\Documents\Reports\Sales Metrics\Tasting Room\Data Files\Sale Detail\
copy/paste the link in my browser works fine, both forward slash and back slash addresses.
What am I doing wrong?
Sep 01 2023 07:22 AM
Perhaps you have other names. Please try
let
Source = Table.SelectRows(Excel.CurrentWorkbook(), each ([Name] = "FilePath"))[Content]{0}[Column1]{0},
FullPathSales = Source & "test/testflow 01.xlsx",
getSales = Excel.Workbook(Web.Contents(FullPathSales), null, true)
in
getSales
assuming we are in root, and change subfolder/filename on your actual ones.