I have increasingly found myself searching through older .pbix files looking for a handy function that I DO NOT want to rewrite. Both the looking for and the rewriting of functions are laborious, frustrating, and above all, unnecessary endeavours.
By using her extremely helpful Curbal vlogs, Ruth Pozuelo pointed me to a (now obvious) solution: store the functions as text in a repository on GitHub. This has a number of advantages…
- My best/most useful code is (re)discoverable
- These snippets of code are shareable: knowledge shared is knowledge doubled
- By publishing publicly, I am motivated to document the code properly
I’m also more likely to write short 1-minute reads like this…so here’s a useful little something that’s not technically difficult, but is very dull to (re)write:
Function: Deep Clean Text
Description: Clean data by removing unwanted characters from the source text, and then tidying the result. This function needs only one parameter: the text to clean. The function will remove non-printing characters, clean up white space and return the results in Proper Case.
Example: ‘ Lorem ipsum (dolor) , sit amet , consectetur adipiscing elit . ‘ returns ‘Lorem Ipsum (Dolor), Sit Amet, Consectetur Adipiscing Elit.’
You can find the code here: https://github.com/BettinaE-K/PowerBI-Functions
There is also a ‘single line’ version available, if you don’t want to invoke a function but apply the transformation directly to your query.
Enjoy!