DAX Formatter was created in 2013 to help users format their code based on the Rules for DAX Code Formatting published in October 2012. Because the main goal is to make the code immediately readable and recognizable, DAX Formatter purposely does not provide many options to customize the format. But we are now considering a small change.

Over the years, we only added three options:

  • Separators: the choice between the comma (,) and semicolon (;) separators is automatic, but you can override this setting manually. This option is required to accomplish the different formatting applied by Excel and Power BI with certain locale settings.
  • Lines: how much code to include within a line of code. When we publish DAX samples in books and articles, for educational purposes we favor the short lines setting, which tries to not include more than one argument in each line. The long lines setting allows short function calls to be formatted inline without breaking arguments off into different lines. We suggest considering long lines as a default in real world projects.
  • Light / Dark mode: you can switch the style of the website to dark mode, which changes your background to black.

All these settings are persisted in your cookies if you allow them, so you do not have to change the configuration every time you open www.daxformatter.com.

Defining the formatting rules required weeks of discussion and allowed the adoption of a standard way to write DAX, making it easier to read DAX code written by someone else. However, when we defined the rules, most of the DAX editors available used proportional fonts, which is an unusual choice for any programming or query language. Reading DAX was harder than necessary because the opening round bracket was too close to the last letter of the function name. Therefore, we included this rule:

  • Always put a space before parentheses ‘(‘ and ‘)’

The (intentional) consequence of the rule is that we have a space between the function name and the opening round bracket:

CALCULATE ( [measure], table[column] = 5 )
    table[column] = 5 

These days, most of the DAX editors (in Power BI, DAX Studio, and Tabular Editor) use non-proportional fonts, making this space unnecessary and not easy to include when writing code with IntelliSense. We are now considering changing the formatting rule into this:

  • Always put a space before parentheses ‘(‘ and ‘)’, with the exception of the open bracket after a function name.

By adopting this rule we get this formatted code:

CALCULATE( [measure], table[column] = 5 )
    table[column] = 5 

Should we adopt this change? We would like your feedback.

We are almost convinced of our decision, but we want to make sure we are considering all the elements at stake. For example, changing one of the rules might have an impact on people using code version and batches that automatically format the code at regular intervals or when there is a new release of a mode. We invite you to try the new format and tell us why we should not change it. The main obstacle we have found so far is simply that we are used to reading code this way, which is not enough to stop the change.

You can start using this standard today. Both DAX Formatter and DAX Studio already provide an option to change this setting.

This is the new settings area available in DAX Formatter.

The new option is:

  • Spacing: the Best Practice setting chooses what we consider in the official formatting rules. You can choose to manually enforce the original rule (A space after function) or the proposed change (No space after function). At the time of writing, Best Practice corresponds to the original rule, but when we decide to apply the change to the rules, the behavior of Best Practice will .

A similar option is available in the DAX Studio settings.

By default, the checkbox is unchecked, but future versions of DAX Studio might have the checkbox checked by default after we decide to apply the change to the rules.

It is now your turn to evaluate the change and provide your feedback.

Thanks in advance – Enjoy DAX!