The following steps show how to create a new column in a table using existing custom function code. This works in Power BI as well as in Power Query in Excel:
1. Copy the function code
![](https://i0.wp.com/www.thebiccountant.com/WP/wp-content/uploads/2019/01/1_CopyFunctionCode-1.jpg?resize=817%2C317&ssl=1)
2. Create new blank query in the query editor
![](https://i0.wp.com/www.thebiccountant.com/WP/wp-content/uploads/2019/01/2_CreateNewQuery-1.jpg?resize=293%2C484&ssl=1)
3. Open the advanced editor
![](https://i0.wp.com/www.thebiccountant.com/WP/wp-content/uploads/2019/01/3_AdvancedEditor-1.jpg?fit=840%2C548&ssl=1)
4. Replace existing function code by new one
![](https://i0.wp.com/www.thebiccountant.com/WP/wp-content/uploads/2019/01/4_PasteNewFunctionCode-1.jpg?resize=840%2C608&ssl=1)
5. Rename query (optional)
![](https://i2.wp.com/www.thebiccountant.com/WP/wp-content/uploads/2019/01/5_RenameQuery-1.jpg?fit=840%2C157&ssl=1)
6. Invoke custom function
![](https://i2.wp.com/www.thebiccountant.com/WP/wp-content/uploads/2019/01/6_InvokeCustomFunction-1.jpg?fit=840%2C455&ssl=1)
7. Edit function parameters
![](https://i0.wp.com/www.thebiccountant.com/WP/wp-content/uploads/2019/01/7_FunctionParameters-1.jpg?resize=699%2C306&ssl=1)
Enjoy & stay queryious 😉
Pingback: Adding A Column With Custom Function Code In Power Query – Curated SQL
Pingback: Bulk-extract Power Query M-code from multiple Excel files at once – The BIccountant