Limit text in a TE script - only want X rows of text #460
-
Hi all, question. I use this script in Tabular Editor to format my DAX code and then add the code to the description field so that when you hover over it in Power BI desktop in both the field pane or the field well of a visual, you can see the code.
The problem is if it is a really large measure with many variable declarations and well formatted code, it can run to 50+ lines easily. Often when that happens what you see in the hover-over tooltip is truncated at both the top and bottom. I'd like to limit my m.Description to preferably a row limit, perhaps 20, and if not that, a character limit, though that would be less useful. Rows would be ideal, but I suspect you'd have to get into counting line feeds in the expression. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
By the power of LINQ in C# this can be achieved with: FormatDax (Model.AllMeasures, true);
foreach (var m in Model.AllMeasures)
{
m.Expression = '\n' + m.Expression;
m.Description = string.Join('\n', m.Expression.Split('\n').Take(20).ToArray());
} |
Beta Was this translation helpful? Give feedback.
-
Sorry, my mistake. Use |
Beta Was this translation helpful? Give feedback.
Sorry, my mistake. Use
"\n"
instead of'\n'
.