BLOGS BY TOPIC▼
BLOGS BY AUTHOR▼
BLOGS BY YEAR▼
Posted by Andy Brown on 30 June 2021
You need a minimum screen resolution of about 700 pixels width to see our blogs. This is because they contain diagrams and tables which would not be viewable easily on a mobile phone or small laptop. Please use a larger tablet, notebook or desktop computer, or change your screen resolution settings.
Useful short-cut keys for use in the DAX formula editor
Who knew DAX had so many useful undocumented short-cut keys? Not us - thanks to XXL BI for bringing these to our attention.
There's a longer list on their blog; this page just shows the ones which we think the average DAX programmer will find useful.
Commenting and uncommenting lines
This is something you can do in DAX Studio, but I didn't realise there was a short-cut key to do it in Power BI:

Suppose that you want to comment out these two variables.
The magic short-cut key to press is Ctrl + / (this alternately comments out the code, then uncomments it):

The result of pressing the above key combination once for our example.
Replacing multiple instances of the same word
This is so useful! Suppose that you want to change the name of the TotalSales variable in the code fragment below to (say) AllSales:

Start by clicking on any instance of the word you want to replace.
Having clicked in the word you want to replace, press one of the following key combinations:
Key | What it does |
---|---|
Ctrl + D | Adds each subsequent word into the current selection. |
Shift + Ctrl + L | Selects all occurrences of the word in the current formula. |
Here's what pressing Ctrl + D twice in arow would give for the above formula, after initially clicking on the word TotalSales:

You can now type in your new variable name, and it will overwrite each of the selected words!
Adding in text for multiple lines
In Visual Studio and SQL Server Management Studio you can use the Alt key to select multiple insertion points, but I never knew you could so something similar in DAX!
Suppose that you want to change the variable names and formulae in the example below:

We want each variable to hold exactly half of the number of rows in each table.
You want your final code to look like this:

For the final code, we've prefixed each variable name by Half and added / 2 to the end of each formula.
To do this, position the cursor at the start of the first word:

Click at the first insertion point.
Now press Ctrl + Alt + Down arrow to extend this selection point downwards:

Anything you type in will be added to each line at the selection point.
You could then repeat the trick to add the / 2 to the end of each line.
Bringing back Intellisense
Although this may not be that useful for users of DAX, for trainers it'll be invaluable. You often have to press the Esc key when training to get rid of Intellisense bubbles like the one shown below, because they tend to hide everything else in your formula:

Power BI is suggesting ways to complete the function.
To get it back again, you can just press Alt + I:

Pressing this key combination will bring the Intellisense prompt back up again.
Moving lines up and down
Suppose that you for the example below you want to move the second variable declaration before the first one:

Start by clicking within the line you want to move.
The keystroke to move this line up (or down) is simple!
Direction | Key combination |
---|---|
Up | Alt + Up arrow |
Down | Alt + Down arrow |
Here's what you'll get if you press Alt + the up arrow 6 times for the above example:

The line has been moved up 6 times.
You can hold down the Shift key (unusually; it's usually the Ctrl key) at the same time to copy a line up or down instead of moving it, but this is probably less useful!