My DAX mantra

To me it's more than important to visualize things to better understand how these things interact, this means most of the time I create a mental image to better understand complex systems and how single components of these in systems interact and work in a joined effort.
Of course it's also eminent to name these things. This already has been done by Alberto Ferrari and Marco Russo in their book "The definitive Guide to DAX", but sometimes I have my difficulties to fully grasp the intricate workings of something called "Evaluation Context", "Context Transition", "Expanded Tables", and the like.

This is another reason why I write about DAX, if my writings help others to better understand DAX, I can be sure that I'm on my way to truly get grip on it. In Power BI we can decide to use DAX for the creation of a calculated column or a measure, here I start with measures. Even if it seems to be more intuitive to start with calculated columns, this just holds true until you stare at an error message like this "A circular dependency was detected ...". From my point of view it's important to understand some of the concepts named above to solve the issue at hand.

My personal mantra whenever I write a measure is this

  • It's the table, it's the table, that fuels my expression

This always reminds me  why this

the measure = 'tablename'[aColumn]

is not sufficient, and I have to rewrite it in this way

the measure = SUM('tablename'[aColumn])

Even if it's maybe not that obvious, but whenever I ask for the measure, maybe billions of rows are aggregated to return a single value (thanks, that there is something like the speed of thought fueled by the xvelocity engine, the column oriented in-memorey engine of the Tabular model).

 

It's simple to visualize a table, a structure that holds data, and this structure has columns and rows, from a technical perspective this structure can be described more accurately, but would not help to better understand DAX.

The next thing I visualize is the following: whenever i ask for the measure, I visualize two Power BI visuals. The table visual and the card visual. The primer, because it looks close  to the structure of the object, I called table. The latter, because it just displays a single value.

 

The weird Year-To-Date calculation

In this little Blog-Post you will find my considerations about the Year-To-Date calculation