How to pass a #DAX query to DAX Formatter

In its first two months, DAX Formatter served 3,500 requests and I see the daily trend slowly raising. If you have observed carefully the first articles published on DAX Patterns, you might have seen that you can click the link”Code beautified with DAX Formatter”.


When you click that link, you open the DAX Formatter page copying the query/formula shown in the box. The good news is that you can implement the same behavior in your articles/blogs/posts by using a GET or POST call.

The easiest way is passing the query into the URL of a GET command:

The &fx argument is the dax code you want to format. The &r argument is optional and can be US (the default), UK or Other. Using Other you use the semicolon ( ; ) as a list separator, and comma ( , ) as decimal point, instead of the , and . settings used for US and UK. Here are two examples of the same query formatted with the two settings.,Customer[Occupation]=”Student”)&r=US;Customer[Occupation]=”Student”)&r=EU

Using the URL might have different limits for its length, depending on the browser. We can consider 2000 characters as a practical limit. You can overcome this limitation by using a POST command. Here is an example of a simple html form that pass the content of a textbox as the query to format:

<form action=”” method=”post”>
<input type=”hidden” name=”r” value=”US” />
<textarea name=”fx”>EVALUATE calculatetable(Customers,Customer[Occupation]=”Student”)</textarea>
<input type=”submit” />

I have also received many feedback about many possible improvements of DAX Formatter – we’ll work on it, you just have to wait… but thanks for the support and appreciation!

UPDATE Feb 27, 2014

You can now use the URL syntax with the additional arguments:

embed=1 : request only the HTML formatted code

font=n : optional – set the font size

For example:,Customer[Occupation]=”Student”)&r=US,Customer[Occupation]=”Student”)&r=US

Article written by
Post originally appeared on:
 Enclose code in comments with <PRE></PRE> to preserve indentation.