Forum Discussion
Power Query Folding breaking query
Hi Guys,
I have notied that when i am using path like this within Folder.Files:
let
path = Text.Combine("D:\BundleSetsRepositories\cost-mgmt-data1")
in
patheverything is working but when i am trying to use dynamic path like :
let
path = Text.Combine({Text.Replace(paramLocalRepositoryPath, "/", "\\"), paramRepository}, "\\")
in
path
power bi hangst while publishin into workspace.
Why?
How to fix it?
Best,
Jacek
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
11 Replies
- lbendlinSuper User
Folder.Files queries do not fold. Only query sources that support some sort of query language like SQL, SOQL, or OData do fold.
Dynamic sources may be rejected by the formula firewall. You need to hide the dynamic part so that the firewall doesn't see it.
https://learn.microsoft.com/en-us/power-query/data-privacy-firewall
- jaryszekSuper User
thanks
- johnbasha33Super User
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
SourceYou create a parameter called
Environmentwith values "Local" or "Service".This way ➔ When you publish, and
Environmentis "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
SourceDid I answer your question? Mark my post as a solution! Appreciate your Kudos !!
- jaryszekSuper User
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
-
- jaryszekSuper User
Ok i tried:
Example: let Source = if Environment = "Local" then Folder.Files(Text.Combine({Text.Replace(paramLocalRepositoryPath, "/", "\\"), paramRepository}, "\\")) else null in Source
but it seems that is not solving the case for me...can anybody try?
It still reading Folder.Files as dynamic one.
I tried to put it into function or Expression.Evaluate but effect was the same...
Ah how to solve the case using M Code not having sharepoints or blob storagas involved?
Best,
Jacek- v-venuppuCommunity Support
Hi jaryszek ,
Thank you for reaching out to Microsoft Fabric Community.
Thank you lbendlin johnbasha33 for the prompt response.
A better way is to use a lambda function to defer execution — this avoids Power BI evaluating the Folder.Files line unless explicitly called:
let
getSource = () =>
Folder.Files(Text.Combine({Text.Replace(paramLocalRepositoryPath, "/", "\\"), paramRepository}, "\\")),Source = if Environment = "Local" then getSource() else #table({}, {})
in
SourceThis ensures Folder.Files is only invoked when Environment = "Local".
It means that I have to hardcode it within code? How to skip this error?
No.You can parameterize Web.Contents, but you must follow Power BI's rules for safe and static URL paths.
Safe usage of Web.Contents with parameters:
Let
baseUrl = "https://raw.githubusercontent.com/",
filePath = "your-org/repo/main/data.csv",
fullUrl = baseUrl & filePath,
Source = Web.Contents(baseUrl, [RelativePath = filePath])
in
SourceThis is considered "safe" and Power BI can validate it. But passing the full URL as a single dynamic string like Web.Contents(dynamicUrl) can break the validation engine.
If this post helps, then please consider Accepting as solution to help the other members find it more quickly, don't forget to give a "Kudos" – I’d truly appreciate it!
Thank you. - jaryszekSuper User
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
- jaryszekSuper User
nope, we are waiting, support is not working from Microsoft
- v-venuppuCommunity Support
Hi jaryszek ,
We are following up once again regarding your query. Could you please confirm whether the issue has been resolved through your support ticket with Microsoft?
If so, we would appreciate it if you could share the resolution or any key insights here to benefit others in the community. If we don’t receive a response, we will proceed with closing this thread.
If you need further assistance in the future, feel free to start a new thread in the Microsoft Fabric Community Forum. We will be happy to support you there.
Thank you.
- v-venuppuCommunity Support
Hi jaryszek ,
Thank you for your patience. The concerned team is looking into the issue, but it may take some time to resolve. As there is already an open ticket with Microsoft, we are closing this thread for now. If you encounter any further issues, please feel free to start a new thread in the community forum, we will be happy to assist you.
Thank you for being part of Fabric community Forum.