Is there a way to specify or force data type of calculated member?

754 Views Asked by At

I've got data type of every measure in my cube specified as Currency. I've also got calculated members, some of them have iif(isempty([Measures].[Measure1]) or [Measures].[Measure1] = 0, null, 100 * [Measures].[Measure2] / [Measures].[Measure1]) logic.

I'm accessing this cube using MdxClient (it uses AdomdCommand.ExecuteXmlReader internally) and have noticed that some of this calculated members are returned as xsd:double not xsd:decimal. So I assume that they are calculated as Double not Currency. Query results are mapped to strongly typed data set at client side, so returned type is important to me.

I can 'force' ssas to return xsd:decimal by wrapping each of calulated members with VBA!CDec or just CDec, but this seriously degrades perfomance.

Is there a smarter way to set or force calculated member to be Currency? Or at least be returned as xsd:decimal by AdomdCommand.ExecuteXmlReader?

2

There are 2 best solutions below

1
On

Have the code of calculated member this way:

MEMBER [Measures].[CurrencyMeasure] 
AS
iif(isempty([Measures].[Measure1]) or 
[Measures].[Measure1] = 0, null, 
100 * [Measures].[Measure2] / [Measures].[Measure1]), FORMAT_STRING="Currency"
0
On

I believe that it is not possible to set the data type of your calculated measures. The data type will be assigned based on the measures used in your calculation as well as the type of calculation you are performing.