GollyJer
GollyJer

Reputation: 26752

How do you add a line break after the first `=` in PowerBI measures when using Tabular Editor c# scripts?

The FormatDax function in Tabular Editor doesn't put a newline after defining the Measure name. How do you update all the Measure formulas to include a newline after using the FormatDax function?

For example. Turning this...

Count = DIVIDE (
    COUNT ( Tests[Lot] ),
    DISTINCTCOUNT ( Tests[Part Number] )
)

Into this...

Count = 
DIVIDE (
    COUNT ( Tests[Lot] ),
    DISTINCTCOUNT ( Tests[Part Number] )
)

Upvotes: 0

Views: 413

Answers (1)

GollyJer
GollyJer

Reputation: 26752

This took some time to figure out. Leaving a Q&A for easier finding next time.

// C# Script
FormatDax(Model.AllMeasures);

foreach(var measure in Model.AllMeasures)
{
    measure.Expression = Environment.NewLine + measure.Expression;
}

Upvotes: 1

Related Questions