DAX Syntax Highlighting for Notepad++

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.

Downloads

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

Check the continuously updated list of DAX functions and operators.

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

I now added AutoComplete to the DAX file.

Just download it again and replace the old one. Version number is included in the file as a comment.

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.

Functions

CALENDAR
CALENDARAUTO
DATE
DATEDIFF
DATEVALUE
DAY
EDATE
EOMONTH
HOUR
MINUTE
MONTH
NOW
SECOND
TIME
TIMEVALUE
TODAY
WEEKDAY
WEEKNUM
YEAR
YEARFRAC
CLOSINGBALANCEMONTH
CLOSINGBALANCEQUARTER
CLOSINGBALANCEYEAR
DATEADD
DATESBETWEEN
DATESINPERIOD
DATESMTD
DATESQTD
DATESYTD
ENDOFMONTH
ENDOFQUARTER
ENDOFYEAR
FIRSTDATE
FIRSTNONBLANK
LASTDATE
LASTNONBLANK
NEXTDAY
NEXTMONTH
NEXTQUARTER
NEXTYEAR
OPENINGBALANCEMONTH
OPENINGBALANCEQUARTER
OPENINGBALANCEYEAR
PARALLELPERIOD
PREVIOUSDAY
PREVIOUSMONTH
PREVIOUSQUARTER
PREVIOUSYEAR
SAMEPERIODLASTYEAR
STARTOFMONTH
STARTOFQUARTER
STARTOFYEAR
TOTALMTD
TOTALQTD
TOTALYTD

ADDMISSINGITEMS
ALL
ALLEXCEPT
ALLNOBLANKROW
ALLSELECTED
CALCULATE
CALCULATETABLE
CROSSFILTER Function
DISTINCT
EARLIER
EARLIEST
FILTER
FILTERS
HASONEFILTER
HASONEVALUE
ISCROSSFILTERED
ISFILTERED
KEEPFILTERS
RELATED
RELATEDTABLE
SELECTEDVALUE
SUBSTITUTEWITHINDEX
USERELATIONSHIP
VALUES

CONTAINS
CUSTOMDATA
ISBLANK
ISERROR
ISEVEN
ISLOGICAL
ISNONTEXT
ISNUMBER
ISONORAFTER
ISTEXT
LOOKUPVALUE
USERNAME

AND
FALSE
IF
IFERROR
NOT
OR
SWITCH
TRUE

ABS
ACOS
ACOSH
ASIN
ASINH
ATAN
ATANH
CEILING
COMBIN
COMBINA
COS
COSH
CURRENCY
DEGREES
DIVIDE
EVEN
EXP
FACT
FLOOR
GCD
INT
ISO.CEILING
LCM
LN
LOG
LOG10
INT
MROUND
ODD
PI
POWER
PRODUCT
PRODUCTX
QUOTIENT
RADIANS
RAND
RANDBETWEEN
ROUND
ROUNDDOWN
ROUNDUP
SIGN
SQRT
SUM
SUMX
TRUNC
DATATABLE
ERROR
EXCEPT
GENERATESERIES
GROUPBY
INTERSECT
ISEMPTY
NATURALINNERJOIN
NATURALLEFTOUTERJOIN
SUMMARIZECOLUMNS
Table Constructor
TREATAS
UNION
VAR

PATH
PATHCONTAINS
PATHITEM
PATHITEMREVERSE
PATHLENGTH

ADDCOLUMNS
AVERAGE
AVERAGEA
AVERAGEX
BETA.DIST
BETA.INV
CHISQ.INV
CHISQ.INV.RT
CONFIDENCE.NORM
CONFIDENCE.T
COUNT
COUNTA
COUNTAX
COUNTBLANK
COUNTROWS
COUNTX
CROSSJOIN
DATATABLE Function
DISTINCTCOUNT
EXPON.DIST
GENERATE
GENERATEALL
GEOMEAN
GEOMEANX
MAX
MAXA
MAXX
MEDIAN
MEDIANX
MIN
MINA
MINX
PERCENTILE.EXC
PERCENTILE.INC
PERCENTILEX.EXC
PERCENTILEX.INC
POISSON.DIST
RANK.EQ
RANKX
ROW
SAMPLE
SELECTCOLUMNS
SIN
SINH
STDEV.P
STDEV.S
STDEVX.P
STDEVX.S
SQRTPI
SUMMARIZE
TAN
TANH
TOPN
VAR.P
VAR.S
VARX.P
VARX.S
XIRR
XNPV

BLANK
CODE
CONCATENATE
CONCATENATEX
EXACT
FIND
FIXED
FORMAT
LEFT
LEN
LOWER
MID
REPLACE
REPT
RIGHT
SEARCH
SUBSTITUTE
TRIM
UNICHAR
UPPER
VALUE

Operators

+ – * / ^ = > < >= <= <> & && || !

Related Posts

Comments (17)

Hi there; wondered if you wanted to add autocomplete functionality to this? If you add a DAX.xml file to your ProgramFiles\Notepad++\plugins\APIs\ folder with entries for each function in a specified format (see below), then the autocomplete (like Intellisense) works in Notepad++:

Sample structure for each function:

<Param name = "” />
” />
<Param name = "” />
<Param name = "” />

Please send me a note if you would like my initial draft of this document. I just don’t have a good way to scrape all of this updated information and populate this file (which I suspect you may already have).

Hi Sascha

Thank you so much for your work on this!

I use an M UserDefined in Notepad++ and it’s a lifesaver. I’m starting out learning DAX and this will be a fantastic help. I would also love the Intellisense functionality that Geoff is offering as I make use of that in M already and it’s great!

Sascha D. Kasper

Hi Geoff,
yes, I would like this very much. I tried before but got stuck and then had to deal with other things first. I would very much appreciate your help here. Thanks.

Sascha D. Kasper

Hi Zedleb,
would you mind sharing the ‘m.xml’ file? I do have one, but am not very happy with it, to be honest.
If Geoff is kind enough to provide his draft, I will take another shot on autocomplete for DAX.
Thank you for your feedback.

@Sascha thank you for sharing this work. It is really helpful for me.
The Intellisense functionality @Geoff referred would be the cherry on top of the cake .
Great work

Sascha D. Kasper

Thank you, Jose. Much appreciated. Please share, if you find it useful. I will keep working on Auto completion. Just need to make some time for it.

Sascha D. Kasper

Hi again,
I now added AutoComplete to the DAX file. Just download it again and replace the old one. If you are not sure, check the version number (a comment in the file). It should be 2.05.
Let me know if it works.

Sascha D. Kasper

Hi again,
I now added AutoComplete to the DAX file. Just download it again and replace the old one. If you are not sure, check the version number (a comment in the file). It should be 2.05.
Let me know if it works.

Sascha D. Kasper

Hi again,
I now added AutoComplete to the DAX file. Just download it again and replace the old one. If you are not sure, check the version number (a comment in the file). It should be 2.05.
Let me know if it works.

Hi Sascha – how can I reach you to send you my work in progress on the autocomplete? I cannot seem to find a contact page on your website.

Sorry for the multiple posts. I looked into your revised DAX xml file and looks great.

One point that would improve this even further would be to expand each keyword with description and required parameters e.g. CALCULATETABLE below:

<Param name = " ” />
<Param name = " ” />
<Param name = " ” />

Sascha D. Kasper

yes, that’s true. frankly, the current version with auto-complete was what I could do quickly and I found it better than nothing. Adding description and parameters is certainly on the backlog.

Sascha D. Kasper

Updated the file (now version 3.01) to include

  • Parameters
  • Return Value
  • Description

See the screenshots in the updated post for details.

I did only preliminary testing, so if you find any issues, please let me know.

Hi Sascha,

Firstly, kudos to you for creating such a great tool!

Secondly, I could get autocomplete to work but I couldn’t see the parameters, return value and description option and I’m pretty sure I’m using the version 3.01 file.

Thanks

Hi Luke, thank you for your feedback. I am not sure what to tell you. I just double checked and it works fine. Some things to consider:

1. please open the DAX.xml file and check the version to make sure it is 3.01
2. the syntax is case sensitive. I.e. using ‘CALCULATE’ would work, but ‘calculate’ would not.
3. the parameters and value options are only displayed once you type the ‘(‘. e.g.: ‘ = IF( ‘. NOT after just typing ‘IF’

Please check these things. Thank you.

Daniel Holth

Thanks for putting this together. They way you grouped the keywords is intuitive. Lets me easily use this with dark theme by swapping for brighter colors on black background.

Cheers!

Leave a Reply

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