Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
Aaron_C
Frequent Visitor

Tabular Editor 2 - Setting DataType of a new measure

Hi all,

When creating a new measure, I would also like to set the DataType for the measure, however when trying the below script, I receive an error telling me that "Property or indexer 'Measure.DataType' cannot be assigned to -- it is read only.

Is there a way to set data types with Tabular Editor 2??

//Creates default hex colour measures

var measureTable = Model.Tables["Calculations"]; // Gets the table object specified

var newMeasure = measureTable.AddMeasure( // Add new measure to specified measure table
"Hex Red", // Name
"#E3A711", // DAX Expression
"Conditional\\Tabular Editor Test\\" // Puts into Display Folders dynamically
);
newMeasure.FormatDax(); // Formats DAX automatically
newMeasure.IsHidden = true; // Set hidden or visible
newMeasure.DataType = DataType.String;

Thanks,
Aaron

1 ACCEPTED SOLUTION
v-rzhou-msft
Community Support
Community Support

Hi @Aaron_C , 

 

As far as I know, you can use the Properties view to review and edit the value of all properties of the currently selected object(s) such as the Name, Expression and Hidden properties, in the TOM Explorer.
For measures, this is where you can set the Format String, for example. For more information,

see Properties view.

 

Best Regards,
Rico Zhou

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

1 REPLY 1
v-rzhou-msft
Community Support
Community Support

Hi @Aaron_C , 

 

As far as I know, you can use the Properties view to review and edit the value of all properties of the currently selected object(s) such as the Name, Expression and Hidden properties, in the TOM Explorer.
For measures, this is where you can set the Format String, for example. For more information,

see Properties view.

 

Best Regards,
Rico Zhou

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
Sept PBI Carousel

Power BI Monthly Update - September 2024

Check out the September 2024 Power BI update to learn about new features.

September Hackathon Carousel

Microsoft Fabric & AI Learning Hackathon

Learn from experts, get hands-on experience, and win awesome prizes.

Sept NL Carousel

Fabric Community Update - September 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors