Power BI is turning 10, and we’re marking the occasion with a special community challenge. Use your creativity to tell a story, uncover trends, or highlight something unexpected.
Get startedJoin us at FabCon Vienna from September 15-18, 2025, for the ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM. Get registered
First of all we are going to open a notepad and paste our function like the following example format:
let TextAsNumber = (valor as number) => let Mostra = "The number is: " & Text.From(valor) in Mostra in TextAsNumber
Save file as a ".pq" file to your repository. In this case I'm going to use my github.
Note: pq extension is just if you want to work with it using power query sdk in visual studio.
Then on Power Bi Desktop Edit Queries just get data from Blank Query and paste the code below replacing the string with raw path from your github, repo or local path (in this last case you should change the word Web to File for contests).
= Expression.Evaluate(Text.FromBinary(Web.Contents("https://raw.githubusercontent.com/ibarrau/PowerBi-code/master/PowerQuery/PQFun.pq")),#shared)
That code will create for us a function in edit query from a repository. It runs a function from text validating it with #shared (a datasource on power bi with actual functions)
That's all folks, now you have a custom fuction in power bi from ".pq" file.
Hope this helps to manage a good repository of custom functions. Not only for having a better administration but also for reusing useful functions on different power bi files.
P/D Schedule Refresh with Expression.Evaluate doesn't work on service. We can now vote for this hoping one day would be available:
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.