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
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
Source
This 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
Source
This 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!
thanks,
i tried your proposition:
let
getSource = () =>
Folder.Files(Text.Combine({Text.Replace(paramLocalRepositoryPath, "/", "\\"), paramRepository}, "\\")),
Source = if Environment = "Local" then getSource() else #table({}, {})
in
Source
It 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