-
Notifications
You must be signed in to change notification settings - Fork 42
Open
Description
Hi Tabular Editor guys,
I couldnt find a place to ask general questions on scripting, working with Daniels example I was trying to create some measures changing the measures format string but first checking the source col to change the format accordingly if Value then "£ #,##0" if Unit then "#,##0" Is there any way to achieve this in the advance scripting, the documentation could be slightly better. As most of the people that would use this are BI developers and not C# programmers.
Your help would be appreciated on this and examples added would be beneficial to get some traction on users using the advance scripting or Macros in T3.
Example code below:
foreach(var c in Selected.Columns)
{
//Set Default Summerizations of all cols to null
c.SummarizeBy = AggregateFunction.None ;
// Hide the base column:
c.IsHidden = true;
var newMeasure = c.Table.AddMeasure(
"Sum of " + c.Name, // Name
"SUM(" + c.DaxObjectFullName + ")" // DAX expression
);
//Set the format string on the new measure:
if (c.Datatype == Datatype.Double)
{
newMeasure.FormatString = "£ #,##0";
Output("Measure will be created for columns with the data type: " + c.DataType.ToString() + " (" + c.DaxObjectFullName + ")");
}
else
{
if(c.Datatype == Datatype.Int64)
newMeasure.FormatString = "#,##0";
Output("Measure will be created for columns with the data type: " + c.DataType.ToString() + " (" + c.DaxObjectFullName + ")");
};
// Display Folder
newMeasure.DisplayFolder = "Basic Measures" ;
// Provide some documentation:
newMeasure.Description = "SUM(" + c.DaxObjectFullName + ")";
}
The code Errors on the If Statement.
if (c.Datatype == Datatype.Double)
{
newMeasure.FormatString = "£ #,##0";
Output("Measure will be created for columns with the data type: " + c.DataType.ToString() + " (" + c.DaxObjectFullName + ")");
}
else
{
if(c.Datatype == Datatype.Int64)
newMeasure.FormatString = "#,##0";
Output("Measure will be created for columns with the data type: " + c.DataType.ToString() + " (" + c.DaxObjectFullName + ")");
};
Metadata
Metadata
Assignees
Labels
No labels