Forum Discussion
Dynamic data source refresh with external stored power query m code
After some searching online, I found a way to get this resolved.
Since #shared contains all functions, you can specify the individual functions used as a record in the environments part of the Expression.Evaluate function.
For instance:
let convert = Expression.Evaluate(Text.FromBinary(
Web.Contents(
"https://raw.githubusercontent.com/...."
)
), [
#"Table.AddColumn" = Table.AddColumn,
#"Text.BetweenDelimiters" = Text.BetweenDelimiters,
#"Text.Replace" = Text.Replace,
#"Record.Field" = Record.Field,
#"Text.AfterDelimiter" = Text.AfterDelimiter,
#"RelativePosition.FromEnd" = RelativePosition.FromEnd,
#"Text.BeforeDelimiter" = Text.BeforeDelimiter
]
) in convert
This actually allows the refresh to work.
Update: Functions, like Web.Contents, Web.BrowserContents, etc are not part of #shared. But in your case you should be able to just add
[ Text.FromBinary = Text.FromBinary ]instead of #shared that might resolve your issue (in combination with the RelativePath and Query sections in Web.Contents). The only part of Web.Contents that must be static is the domain itself.
What is listed in the Data Source dialog? Just this?
https://raw.githubusercontent.com/
- ferryv2 years agoResolver II
That would be the url to the function you're referencing from github, i.e. a hardcoded url.
- lbendlin2 years agoSuper User
That wouldn't be a dynamic source then? Well, I guess "dynamic" is up for discussion here as you can indeed change the text inside the .pq file. Just make sure all used functions are declared in the environment.
- ferryv2 years agoResolver II
The issue was actually the #shared environment that caused the issue. Even when you hardcoded the url.