Forum Discussion

Lutinho's avatar
Lutinho
Frequent Visitor
4 years ago

Load external code from .txt for custom column

Good afternoon community,

 

I have a problem that I am trying to solve. I have a bit of code (for a custom column) that is quite critical for our reporting but which is also annoying to maintain in 6 different reports.

 

With the help of a blogpost (https://blog.crossjoin.co.uk/2014/02/04/loading-power-query-m-code-from-text-files/) I tried to load the code for the custom column externally, but without results. 

 

The point is, I am only trying to load the code for a custom code externally, not all content of the advanced editor. 

 

When creating the custom column I tried code like this:
Expression.Evaluate(Text.FromBinary(Web.Contents("https://xxxxx.xxxx.x.xxx/Subvlak.txt")))

 

Where Subvlak.txt is just a plain .txt with content like this: 

if [Modul] = "035" or ([Modul] = "022" and [#"HPG-Code"] = "003") then "Datacenter" else "Blabla"

 

I then get an error like this: 

Expression.Error: There is an unknown identifier. Did you use the [field] shorthand for a _[field] outside of an 'each' expression?

 

Anyone can help me with this? Thanks in advance!

 

With kind regards,

Lutijn

 

1 Reply

  • v-jingzhang's avatar
    v-jingzhang
    Community Support

    Hi Lutinho

     

    It's a cool idea. I'm afraid it's beyond my scope at present. Hope more people can see this post and give suggestions here. 

     

    Best Regards,
    Community Support Team _ Jing