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…

  1. My best/most useful code is (re)discoverable
  2. These snippets of code are shareable: knowledge shared is knowledge doubled
  3. 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!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.