Microsoft Power BI, Analysis Services, MDX, DAX, M, Power Pivot and Power Query

Step Descriptions And Comments In M Code In Power BI Desktop

The June release of Power BI Desktop has what seems to be a fairly unremarkable new feature in that it allows you to add descriptions to each step in a query in the Query Editor window. However the implementation turns out to be a lot more interesting than you might expect: the step descriptions become comments in the M code, and even better if you write M code in the Advanced Editor window your comments appear as descriptions in the Applied Steps pane.

Take the following M query, entered in the Advanced Editor, as an example:

let
Step1 = 5,
Step2 = 10,
Step3 = Step1 * Step2
in
Step3

There are three variables declared in the let expression which appear as three steps in the Applied Steps pane. The first two steps declare integers and the third multiplies these two integers together, returning 50.

If you right-click on the first step and select Properties, then you can enter a description for the step in the Properties pane that appears:

After you click OK, the description is visible as a tooltip when you mouse-over the step:

If you then open the Advanced Editor window you’ll see the M code for the query has now been changed to include a comment (NB comments in M code start with //):

This is great and pushes me even further towards using desktop in preference to Excel. We just need proper intellisense now and intuitive wizards so you’re not scratching around to find the function you need or translate the equivalent function in Excel. I don’t think either are too far away either.
Got a two week holiday coming up so I’m going to immerse myself fully in this website and KP’s to catch up properly on all the valuable stuff you guys have been posting

I’ll be the odd man out here and say that this is probably one of my least favorite features ever implemented. I favor coding practices that suggest minimizing comments in code, for good reasons. Comments are even less necessary in M than an imperative language.

Follow Blog via Email

Social

Need some help?

As well as being a blogger, I'm an independent consultant specialising in Analysis Services, MDX, DAX, Power BI, Power Query and Power Pivot. I work with customers from all round the world solving design problems, performance tuning queries and delivering training courses, and I am happy to work on short-term engagements. For more details see http://www.crossjoin.co.uk