Tutorials September 30, 2021 · 2 min read

Time saving scripts in Tabular Editor

Two Tabular Editor scripts that format all your DAX measures in one click and add measure expressions as descriptions for quick reference in live reports.

Gregor Brunner Gregor Brunner
Time saving scripts in Tabular Editor

I am sure you are already familiar with Tabular Editor (2 which is free and 3 the monster version that you need to pay for). Did you know though about these two scripts?

  1. Format all your measure DAX expressions in one click.
  2. Add a description to all your measures (the description will be the measure expression itself)

The first one is a quick win and you may have used it before.

What about the second one though? For me this is a huge thing since when working with live reports I do not need to open the dataset anymore to check measure expressions.

You can also take advantage of this when you are in edit mode in the Power BI service.

Tabular Editor icon

1) Formatting Measure Expressions

Copy this code:

Model.AllMeasures.FormatDax();

Then open Tabular Editor from within your report — download it if you have not done so yet.

Tabular Editor interface

Go to Advanced Scripting and paste the script.

Advanced Scripting section

Press play to run the script. This script will automatically run through all your measures and will format them with the best-practice syntax.

Script execution animation

2) Adding Descriptions to Your Measures

For adding descriptions to your measures, use this:

foreach (var m in Model.AllMeasures)
{ m.Description = m.Expression; }

Copy the script into the Advanced Script of Tabular Editor and run it.

Advanced Script interface

The logic of the script is to create a description for all measures with the current measure expression.

Measure description example

The description of the measure will be visible when you hover over the measure. This description is especially useful if you have a live report or if you are looking at your report in the Power BI Service in edit mode.

Hover tooltip animation

If you have some other fantastic scripts and would like to share them, feel free to comment below.