If you are working with DAX and do more than single line statements, you will frequently find yourself wishing for a powerful editor with proper syntax highlighting. Below I explain how to use Notepad++ for that purpose. While I use DAX mostly in Power BI, it of course works just as well with other environments.
First Things First
- This guide is based on the 64-Bit Notepad++ version 7.5.6. You can always download the latest version of Notepad++ here.
- Just below you can download the custom language XML file for easy import into Notepad++ and further customization.
- I also provide a full list (at the time of writing this) of DAX functions and operators for easy copy/paste.
- If you are more of a hands-on person, the steps you need to follow can be found after the download section.
DAX XML file for import into Notepad++
To import the file, start Notepad++, click on Language, Define your Language, Import, navigate to the file and click Open.
Once you imported the file, make sure to click Language again and select DAX from the list. Only then it will be applied to the file you opened.
If you save files with the extension “.dax” and then open these in Notepad++, the XML file will be applied automatically.
User Defined Syntax Highlighting in Notepad++ – Step by Step
Once you have installed and started Notepad++, click on Language, Define Your Language.
This will open the User Defined Language Editor as shown below.
Click on Create New and enter a name (e.g. DAX). Once you have done that enter a value for Ext. (Extension). This will allow Notepad++ to automatically use the correct syntax language for files with that extension. I use dax as extension.
On the Folder & Default tab define the Open and Closed characters for Folding in code 1 style. Then click on Styler and pick the color and font format of your choice (here: orange and bold) and click OK.
On the Keywords List tab, you can proceed in two different ways. The faster way is to copy the full list of functions in the 1st group box, click on Styler for this group and define the style once for all of them.
Alternatively you can split the functions in logical groups and format each of the groups individually. I went with option two, even though I defined the same style for all groups (here: blue and bold). Click OK after defining each style.
On the Comment & Number tab define the Open characters for Comment line style (—) and the Open and Close characters for Comment style (%) respectively. Click Styler for each and define style (here: green) and click OK.
On the Operators & Delimiters tab copy the list of operators into the Operators 1 box, enter the Open and Close characters for Delimiter Style 1 ([ and ]). Then click Styler for each and define your style (here: magenta and bold) and click OK.
All changes will be saved automatically when you close the User Defined Language Editor. I recommend exporting the configuration first, so you have a backup that you can easily import again, if things go awry.
Obviously you can modify these styles as you wish. I find it useful to have a DAX file open while playing around with the styles and immediately see the changes applied to the code.
Copy and Paste Lists
You can find the list of functions and operators after the actual file download for your convenience. Just copy them from there.
Update | 27/04/18 | Version 2.05
Update | 09/05/18 | Version 3.01
- Updated function list with latest additions
- Added ‘return value’, ‘parameters’ and ‘description’ to auto-complete.
Just download it again and replace the old one. Version number is included in the file as a comment.
+ – * / ^ = > < >= <= <> & && || !