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
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
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!
ā
- jaryszek1 year agoSuper 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