Monday, March 19, 2012

Measure data type from UDM to ADOMD

Ok, so here is my dilemma.

I need to get the data type of a measure in ADOMD.NET.

I have a SSAS project which deploys a cube. The measure is defined in this project file as having a FormatString of "Currency" (this is in the "Basic" section of the measure properties in Visual Studio).

I have tried to use the format_string property by using "

Code Snippet

CELL PROPERTIES FORMAT_STRING

", but this still returns "#, #" as the format string.

How do I get the data type of the measure?

Thanks

hello,

MDSCHEMA_MEASURES schema rowset has DATA_TYPE column which contains measure's the data type.

In Adomd.net you can get to this information in 2 ways: either execute schema rowset request directly (with connection.GetSchemaDataSet method), or via metadata objects. Measure object has .Properties collection, and you can find the DATA_TYPE property in it. So Measure.Properties["DATA_TYPE"].Value should contain the data type of the measure. (i think you can compare the values with System.Data.OleDb.OleDbDataType enum values), for example i can test if measure's data type is returned as currentcy with something like this:

(UInt16)measure.Properties["DATA_TYPE"].Value == (UInt16)System.Data.OleDb.OleDbType.Currency

You should be able to get to Measure object either from .Measures colleciton exposed on cube, or by

cube.GetSchemaObject(SchemaObjectType.ObjectTypeMeasure, <unique name of the measure>) as Measure

hope this helps,

No comments:

Post a Comment