There are tools that help you format your DAX code such as Tabular Editor and daxformatter.com. They can only format your DAX one by one. Have you ever found yourself doing that before? Then this blog post is for you. With C# scripting in Tabular Editor, you can format your DAX measures all at once!
Format All DAX Measures at Once with Tabular Editor
If you haven’t done any C# scripting in Tabular Editor, this can be a good introduction for you. There is a tab in Tabular Editor where you can write some C# code to do model operations. You can save your snippets so that you use can them not only in one report, but also in many others.
1. You switch to another tab called “C# Script”:
2. Copy and paste the following C# code:
foreach (var m in Model.AllMeasures)
What the code is doing is to go through each measure and format it one by one. How simple is that!
That’s pretty much it, but there is one thing you need to be careful when formatting DAX through C#. There are a few other ways to accomplish the same, but as the documentation says, avoid writing the code like this:
The followings are the alternatives to the deprecated version:
These alternatives essentially batch all the FormatDAX() function calls into one request.
With C# scripting in Tabular Editor, you can easily format all your DAX measures at once. You can do a lot more stuff with C# scripting, and that can definitely something can separate you from other Power BI developers.