Creating a function manually using M
Just like Excel, Power Query (and Power BI) has many functions that you can use to prepare or transform data. These are, of course, updated regularly by developers. When we use icons and set options in Power Query, the program works hard behind the scenes to generate the code to provide you with results to any functions you may apply to the data.
We can display a list of M functions using the #shared
code in the Power Query formula bar, as explained in Chapter 9, Working with M, in the Using #shared to return library functions section. We can use this to build our data queries, but sometimes, we need to construct personalized functions to make our lives easier and less complicated. By less complicated, we mean being able to address repetitive tasks with one action instead of multiple actions or construct them so that they can be applied to many different queries or arguments. We will use a manual method of creating a custom function by constructing...