DAX · Power BI · Power BI Desktop

Line Breaks And Auto-Indent In The Power BI DAX Formula Bar

The other day I discovered something new (at least to me) while writing the DAX for a measure in Power BI Desktop: when you insert a new line in your DAX expression using SHIFT-ENTER it also auto-indents the code. I asked a few people if this was new because I was sure I hadn’t seen it before, even though I always put line breaks in my code; of course Marco had and said he thought it had been around for a while. Anyway, Marco then commented that most people didn’t know you could even put line breaks in DAX and I thought to myself I should probably write a short blog post about all this, because of course line breaks and indentation make your code much more readable.

Here’s what it looks like to write a DAX measure in Power BI Desktop using line breaks and auto-indent:

To summarise:

  • Press the SHIFT and ENTER keys on the keyboard simultaneously to insert a line break in your DAX code when you are working in the Power BI DAX formula bar
  • Do this after the opening bracket of each function and after the comma of each function argument and the auto-indent will kick in
  • Bonus tip: while typing DAX, if the dropdown list has the function, table, column or measure selected that you want to use, just hit the TAB key to auto-complete. If the dropdown list hasn’t selected what you are looking for and you don’t want to keep typing, use the up and down arrow keys on the keyboard to move up and down the list until you have selected what you want.

Of course there’s always Marco and Alberto’s excellent DAX Formatter service to format your DAX code but this is a lot more convenient.

7 thoughts on “Line Breaks And Auto-Indent In The Power BI DAX Formula Bar

  1. Marcel Schürmann – Switzerland, Lenzburg – Gründer von find Secrets https://find-secrets.com/ Microsoft Business Intelligence und Data Science Consultant.
    Marcel Schürmann says:

    Thanks for the tips.

    Here another tip:
    By using ALT+ENTER (instead of SHIFT+ENTER) you get a linke break without identation.

Leave a ReplyCancel reply

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