THE SQL Server Blog Spot on the Web

Welcome to - The SQL Server blog spot on the web Sign in | |
in Search

SQLBI - Marco Russo

SQLBI is a blog dedicated to building Business Intelligence solutions with SQL Server.
You can follow me on Twitter: @marcorus

A proposal for #DAX Code Formatting #ssas #powerpivot #tabular

I recently published a set of rules for DAX code formatting. The following is an example of what I obtain:

    SUMX (
    FILTER (
        ALL ( Customers ),
        CALCULATE (
            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).

        SUMMARIZE (
            "Num of Rows", FORMAT (COUNTROWS (Audience), "#,#"),
            "Weighted Mean Age",
                SUMX (Audience, Audience[Weight] * Audience[Age]) / SUM (Audience[Weight])

        SUMMARIZE (
        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!

Published Monday, October 22, 2012 3:10 PM by Marco Russo (SQLBI)
Filed under: , , ,

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS


No Comments

Leave a Comment


About Marco Russo (SQLBI)

Marco Russo is a consultant, writer and trainer specialized in Business Intelligence with Microsoft technologies. He runs the SQLBI.COM website, which is dedicated to distribute resources useful for BI developers, like Integration Services components, Analysis Services models, tools, technical information and so on. Marco is certified as MCT, MCDBA, MCSD.NET, MCSA, MCSE+I.

This Blog



Privacy Statement