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.

If you prefer watching over reading, check out the short video below. In it, I use DAX as an example. But it works just the same for M, of course.

Get the Files

Please fill in the short form below. After submitting the form, you will be taken to the download page. You will also receive an email with a direct download link.

Change Log

5.0 – June 13, 2023

  • Tested on version 8.5.3 (64 bit)
  • Added new DAX functions released in Jan-May 2023
    • LINEST
    • LINESTX
    • RANK
    • ROWNUMBER
    • EXTERNALMEASURE
    • MATCHBY
Find all DAX functions here: https://dax.guide

This guide is based on the 64-Bit Notepad++ version 8.5.3. You can always download the latest version of Notepad++ here.

Follow the instructions below to

  • enable syntax highlighting
  • enable auto-completion
  • modify the syntax colors to your liking

The same process works with the files for M (PowerQuery) over here.

Let's Go

Extract the received ZIP archive and open the folder location in your file explorer. Make sure there is an “m.xml” file and an “AutoComplete” folder.

I am aware that the screenshots show DAX, just select M instead. The process remains the same.

"dax.xml" in the extracted archive folder

Syntax Highlighting

To import the file,

  • start Notepad++,
  • click on LanguageDefine your Language, Import,
  • navigate to the file and click Open.
  • Close the Define your Language dialog.
Click on the image for a larger view
Click on the image for a larger view

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 don’t see DAX in the language menu right away, you may have to restart Notepad++.

Click on the image for a larger view
Click on the image for a larger view

Auto Completion

This will give you syntax highlighting. If you want to have the auto-complete functionality, you need to

  • navigate to the extracted folder
  • enter the “AutoComplete” folder
  • copy the file “m.xml” from the AutoComplete folder to the folder “autoCompletion” inside the Notepad++ program directory. In my case this is “C:\Program Files\Notepad++\autoCompletion
    • You will get a warning, requiring Administrator permissions.
  • Confirm the warning and restart Notepad++
Click on the image for a larger view

Modifying The Colors

I tried to pick colors that work equally well with the light and dark theme of Notepad++. However, colors that work well for me, might not be that great for you.

Fortunately, you can adapt them very easily. In Notepad++ click on Language, User Defined Language, Define your Language.

Select M from the User Language drop-down:

Click on the image for a larger view
Click on the image for a larger view

Use the tabs to find the elements you want to modify:

  • Folder & Default
  • Keywords
  • Comment & Number
  • Operators & Delimiters
Click on the image for a larger view
Click on the image for a larger view

Click on the Styler button and adjust any attributes you want

  • Font
  • Size
  • Bold
  • Italic
  • Underline
  • Foreground color
  • Background color
pbi_dax_npp_05
Click on the image for a larger view

29 Comments

  1. 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).

  2. 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!

  3. 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.

  4. 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.

  5. @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

  6. 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.

  7. 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.

  8. 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.

  9. 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.

  10. 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.

  11. 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 = " ” />

  12. 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.

  13. 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.

  14. 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

  15. 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.

  16. 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!

  17. Walid Saafan

    Thanks for your excellent work, We really appreciate your effort

  18. Sascha D. Kasper

    Thank you, Walid. Glad to see that it is useful for people.

  19. Cameron Turner

    Hi Sascha,

    There is an error in the 3.04 V of the XML.

    I think that you have added the autocorrect of the three new functions, but have not put them into the key words. This then causes an “Fail to import” error on notepad++.

    I found that if I delete the three auto complete inputs then the code will import successfully.

    Thanks for your continued hard work!

  20. Rodney Moulder

    Hi Cameron are you able to send me the a working version I am getting failed to import error

  21. Sascha D. Kasper

    Hi Cameron. Thank you for pointing this out. You’re right, of course. I will provide a fixed import file tomorrow. My apologies for the inconvenience!

  22. Sascha D. Kasper

    Hi Rodney. I will provide a fixed import file tomorrow. Sorry about that.

  23. Sascha D. Kasper

    Rodney, the fixed XML file is now available for download.

  24. Sascha D. Kasper

    Cameron, fixed XML file is now online for download. I forgot to close a tag… Thank you again for letting me know.

  25. Walid Saafan

    Hi Sascha,
    Thanks for your effort.
    I added the updated dax.xml to notepad++ as per your instructions, selected DAX from the language, enable auto-completion preference.
    the auto completion for DAX functions is not working! it is colored blue after full typing.
    Your help is appreciated.
    Thanks

  26. Sascha D. Kasper

    Hi Walid Saafan,
    thank you for your input. I fixed the file and added two new functions, which were only released yesterday (see release notes for details).
    Please let me know, if it works for you.
    Cheers.

  27. Hi 🙂 I subscribe, but didn’t receive the files :'(

  28. Sorry to hear that. I will send the files directly via email to you.

Leave a Comment

Your email address will not be published. Required fields are marked *

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