Main Question :
I have created various custom functions that I frequently use. I would like to store them in a repository somewhere and call them whenever necessary. I know that I can save all those functions in an Excel file and save it in OneDrive. But I would like to save them somewhere I can edit and share them easily like GitHub.
And finally, if it is possible, can we make a private repository? If i want few of my functions to be shared privately, can I protect/lock them using a password?
Helpful Resources:
Understanding the following probably might be helpful in answering this.
Resource 1:
There is a function called #shared
in PowerQuery which lists down all the functions available and their respective description. You can know more about it at the following post.
I think understanding how does this function (#shared) work and Where is this information being extracted from will be helpful in answering My main question above. Which is basically, how can I make something like this for my custom functions?
Resource 2:
One possible help for this question would be an existing repository in Github by Hugoberry.
Note:
For those who are looking for an answer to this question, the answer provided by Nacho works for creating a function with Manual Entry(Text/Number) inputs.
It does not work for functions that refer to a table/parameter.
After taking a long path on this I solved it. Below are the steps to do this:
let
TextAsNumber = (valor as number) =>
let
Mostra = "The number is: " & Text.From(valor)
in
Mostra
in
TextAsNumber
Then go to the file in github and click on "Raw"
Copy the URL. Open Power Bi Desktop edit queries. Get Data from blank query and paste this:
= Expression.Evaluate(Text.FromBinary(Web.Contents("https://raw.githubusercontent.com/ibarrau/PowerBi-code/master/PowerQuery/PQFun.pq")),#shared)
Note: The same thing can be made with local path too, just replace Web by File on "Contents". Like so:
= Expression.Evaluate(Text.FromBinary(File.Contents("C:\Users\username\Documents\Folder\Sub-Folder\PQFun.pq")),#shared)
Hope this helps you to manage better the custom function repository.
PS: I'm not sure if you are going to be able to refresh in Service.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With