Making a Code Block from a Power BI Query Readable Using Notepad++

Oftentimes, when looking at the Advanced Editor window on a Power BI query, you will see that the SQL query in one of the steps has been compressed into fewer lines – perhaps even only one line; minified with Power Query codes like “#(lf)” (line feed) and “#(tab)”.

To make this more readable, you can copy the code block from Power BI into a Notepad++ window, and replace these Power Query codes with escape sequences that will format the code into multiple lines that are easier to read.

Once the code is in Notepad++, open the Replace window with Ctrl+R, and select the Extended radio button in the Search Mode box in the lower left-hand corner.

Replace box in Notepad++

Put the offending Power Query codes into the “Find what” field, and the corresponding escape sequence into the “Replace with” field. Select Replace All.

Repeat this with each type of code that needs to be replaced. Afterwards, you can read and modify the code block, if you wish.

To convert the whole code block back into its original format, reverse the steps, putting the escape sequence in the “Find what” field and the original Power Query code in the “Replace with” field and select Replace All again.

%d bloggers like this: