I recently published a set of rules for DAX code formatting. The following is an example of what I obtain:
ALL ( Customers ),
COUNTROWS ( Sales ),
ALL ( Calendar[Date] )
) > 42 + 8 – 25 * ( 3 – 1 )
+ 2 – 1 + 2 – 1
+ CALCULATE (
2 + 2 – 2
+ 2 – 2
– CALCULATE ( 4 )
The goal is to improve code readability and I look forward to implement a code formatting feature in DAX Studio. The DAX Editor already supports the rules described in the article.
I am also considering whether to add a rule specific for ADDCOLUMNS / SUMMARIZE because I would like to see the “pairs” of arguments to define a column in the same row or with a special indentation rule (DAX expression for a column is indented in the line following the column name).
“Num of Rows”, FORMAT (COUNTROWS (Audience), “#,#”),
“Weighted Mean Age”,
SUMX (Audience, Audience[Weight] * Audience[Age]) / SUM (Audience[Weight])
Audience[Weight] > 0
Targets[Target] = “Maschi”,
‘Date'[Year] = 2010,
‘Date'[MonthName] = “January”
I would like to get feedback for that – you can use comments here or comments in original article. Thanks!
Originally appeared on: http://sqlblog.com/blogs/marco_russo/archive/2012/10/22/a-proposal-for-dax-code-formatting.aspx