Forum Discussion
Power Query Folding breaking query
- 1 year ago
thanks,
i tried your proposition:let getSource = () => Folder.Files(Text.Combine({Text.Replace(paramLocalRepositoryPath, "/", "\\"), paramRepository}, "\\")), Source = if Environment = "Local" then getSource() else #table({}, {}) in SourceIt still hanging power bi while publishing. It is like it skipping if else statement and triggering dynamic path no matter of it.
I created support case.
Best,
Jacek
Because Folder.Files() (and similar M functions that reference local paths) are NOT supported in Power BI Service.
Power BI service (Fabric workspace) cannot access your local machine's file system like D:\... drive.
It expects:
-
Cloud paths (SharePoint, OneDrive, Azure)
-
Or properly parameterized Web.Contents() links
When you publish, Power BI tries to validate the data source path and cannot resolve your dynamic local path ➔ it hangs or errors.
Even hardcoded local paths sometimes cause issues — but with dynamic path, Power BI cannot even check or cache the path ahead of time, making it worse.
If you must use Folder.Files locally ➔ disable loading it in the service
You can:
-
Wrap your local source logic inside an
ifblock based on a parameter.
Example:
let
Source = if Environment = "Local"
then Folder.Files(Text.Combine({Text.Replace(paramLocalRepositoryPath, "/", "\\"), paramRepository}, "\\"))
else null
in
Source
You create a parameter called Environment with values "Local" or "Service".
This way ➔ When you publish, and Environment is "Service" ➔ it does NOT try to access local path, avoiding crash.
Switch to SharePoint, OneDrive, or Azure for file storage
If these files are important, move them to SharePoint Document Library or Azure Blob Storage, and connect via SharePoint.Files() or AzureStorage.DataLake().
Use a Dataflow / Lakehouse instead of direct local files
Instead of trying to pull files at report level ➔ you can use Dataflows or Fabric Lakehouses to land the files, then connect.
let
path = Text.Combine({Text.Replace(paramLocalRepositoryPath, "/", "\\"), paramRepository}, "\\"),
Source = if Environment = "Local" then Folder.Files(path) else #table({}, {})
in
Source
Did I answer your question? Mark my post as a solution! Appreciate your Kudos !!
Wow thanks!
Switch to SharePoint, OneDrive, or Azure for file storage
If these files are important, move them to SharePoint Document Library or Azure Blob Storage, and connect via SharePoint.Files() or AzureStorage.DataLake().
It means that it will work without any issues?
And another, more important question.
The same is for Web.Contents... https://raw.githubusercontent.com/ .
It means that I have to hardcode it within code?
How to skip this error?
The only way is to create custom connector or howto handle web.Contents to provide parameter?
Best,
Jacek