If you are a newbie, writing DAX can be intimidating. Especially when you have to take care of all that line formatting, row/column filter contexts and not to mention the brackets.
I am listing down 15 pretty interesting DAX Keyboard Shortcuts in Power BI to help you write and debug your DAX code faster and smarter. Of-course with some of my commentary and gifs too, enjoy!
1. Code Indentation
I’ll give you 2 shortcuts for this
- Tab & Shift + Tab (to indent & outdent) – But the Tab key (indent) will only work if the cursor is at the start of the line
- Ctrl [ & Ctrl ] (to indent and outdent) – On the flipside both these shortcuts will work no matter where your cursor is placed
2. Insert a New Line
- You can use Ctrl + Enter to move to a new line of code
- Or use Shift + Enter (also my favorite) to move to new line of code maintaining the indent of the previous line
3. Activate Intellisense
While writing the code you might press the esc key to get rid of the formula suggestion drop down box (also called intellisense) but if you wanted it back, use Ctrl + Space
4. Comment & Un-Comment the Code
This is one of my favorite shortcuts and I use it all the time to manage & debug my code.
- To comment a line or multiple lines of code – Ctrl + / (if you want to comment more than a line you’ll have to select multiple lines using the shift and arrow keys and the press Ctrl + /)
- To un-comment a line or multiple lines – Ctrl + / (once again)
5. Move Up / Down the Current Line or Multiple Lines
- Select the line or multiple lines and use the Alt + Up Arrow
- Or Alt + Down Arrow to move the code down
6. Copy the Line up or Down
- Use the shortcut Alt + Shift + Up-Arrow or Down-Arrow to copy the line of code up or down
- Your cursor can be anywhere in the current line
7. Write Multiple Lines of Code at Once
Personally speaking I haven’t used it even once but I find it fancy to be able to write multiple lines of (same) code at once.
- Use the Ctrl Alt + Up or Down Arrow to place the cursor in multiple lines at once and then start typing
- The above shortcut will only let you write in contiguous lines but in-case you want to write in multiple non-contiguous lines, first select the lines using Mouse Click and Alt Key and then start typing your DAX Code
Pro Tip #1 – Pressing Esc will not deactivate multiple lines cursor. You’ll have to once click anywhere in the code
8. Find and Replace a Word
This is very helpful especially when you want to make a change at multiple places in your code.
- Select your word
- Then use Ctrl + D – to select the next instance of the same word
- Start typing to replace it
- Pro Tip #1 – You’ll have to type the full word, I am sorry but the Tab for auto-complete will not work
- Pro Tip #2 – Pressing Ctrl + D will only select the 2nd instance of the same word, pressing Ctrl + D again will select the 3rd instance and so on..
- Pro Tip #3 – In case you want to select all instances of the word at once, read the next shortcut 😉
9. Find and Replace all Words at Once
- If you press CTRL + SHIFT + L you’ll be able to select all instances of the word at once
- Then start typing to replace it
- Pro Tip #1 – Protips from the previous shortcut will apply here too 😉
10. Go to a Line Number
Unless your code runs into hundreds of lines, I don’t see it’s use to me. Nevertheless
- Use Ctrl + G and then type the line you want to go to
- For me the (up / down) arrow keys to navigate the code just work fine!
11. Move the Code Screen without moving the Cursor
I really like this one. If your code is long..
- You can use Ctrl + Up / Down Arrow to move the screen (up / down) without moving the cursor’s current position
- It’s great if you want to just look up on the screen for a while but continue working with the code at the same place
12. Deleting a Word & Full Line of Code
- Use Ctrl + Del to delete the word where your cursor is currently active
- Use Ctrl + Shift + k to delete the full line no matter where your cursor is in the current line
13. Select the Entire Line
Use Ctrl + i to select the entire line no matter where your cursor is in the current line
14. Go to the Beginning or End of the Code
- Ctrl + Home takes you to the start of the Code
- Ctrl + End takes you to the end of the Code
- Pro Tip #1 – Pressing Home will take you to start of the current line
- Pro Tip #2 – Pressing End will take you to the end of the current line
15. Open up Shortcuts Screen in Power BI
If you want to take a look at the list of Power BI interface shortcuts just press Shift + ?
Some more Shortcut Riches!
- Created a Tip Card (pdf) on Power Query – Take it!
- If Excel Interests you – 100+ Excel Shortcuts & a Guide on How to Master Them
- VBA Freak ? – 60+ VBA Shortcuts
- Financial Modeling ? – Here are a few Financial Modeling Shortcuts
- Own a Mac ? – Take these Excel Mac Shortcuts
DAX Shortcuts from Other Power BI Pros!
These are also the source of this blog’s inspiration