Using Notepad++ to Easily View Calculation Logic

A quick tip

Posted by David Velleca on January 29, 2019

Quick Tip - Easily View your Logic by Editing Calcs in Notepad++

After Tableau Desktop the next most commonly used application on my computer is probably Notepad++. I use Notepad++ to take notes, edit HTML and XML files and to have a larger screen to review the logic from Tableau Calculated fields. I often get asked to help figure out why a calculated field is not producing the desired result. Sometimes, it's not feasible to review multi-line logic in Tableau, so I leverage Notepad++ for a larger window and some additional help.

I love how the tool has built in language support for common file types, to highlight different operators, keywords and more - it makes it incredibly easy to know when I've forgotten to close a tag in HTML. With a quick XML import you can make the tool reflect Tableau's display of calculated fields.

Notepad++ allows for User Defined Languages, and I've gone through and created a user defined language for Tableau Calculation logic. When the language is selected, it highlights the different functions, comments, LOD keywords and more as they would appear in the calculation window in Tableau Desktop (with the exception of Parameters). If you use Notepad++ either to write or review calculated fields, follow the steps below to import the XML file to leverage the custom language.

  1. First, download the XML file from here. Save the file to your desktop, or somewhere that is easy to navigate to. This file contains the info to specify the delimiters, key words, operators, etc.
  2. In Notepad++, go to the 'Language' menu, and click on 'Define your language...' at the bottom of the menu.
  3. Click the 'Import...' button on the dialog box that pops up.
  4. Browse for the XML file you downloaded a minute ago, then click 'Open' and 'Ok' on the dialog box that tells you your import was successful.
  5. Close the 'User Defined Language' dialog box by clicking the red X in the top right corner.
  6. Go to the 'Language' menu again in Notepad++, and 'Tableau Calcs' should now appear at the bottom of the menu. Note that if it does not, restarting Notepad++ should refresh the languages.

Now, while you edit calculations in Notepad++, the formatting will mimic Tableau Desktop. Check out the video below, and reach out if you have any questions! If you make any modifications or improvements, I'd love to hear them!

Some bonus content - to export the formatting to rich text format for use in emails or the Tableau forum, you can download the NPPExport plugin from here on GitHub. Check out this video for the export in action! Huge thanks to Ken Flerlage for pushing me to take this farther.