Creating custom functions
As we learned in the previous chapter, while native functions are powerful, there are scenarios where custom functions are necessary. In some scenarios, it might not even make sense to add the custom function through the Queries tab as it might only be used once. With that in mind, it sometimes makes more sense to build that custom function into the existing code within the advanced editor. We’ll delve deeper into the process of creating efficient custom functions in M during this section.
As an example, start by building a table from a blank query. Follow these steps to do this:
- Open Power BI Desktop.
- Select Transform data from the Report, Table, or Model View to open the Power Query editor.
- Select New source and then select Blank query from the dropdown. Select Advanced editor from the Home ribbon to open the Advanced editor.
- Enter the following code into the Advanced editor:
let
Scorecard = Table.FromList(
&...