Monday, March 12, 2012

How can we get the round value of a number by MDX?

Hi, all,

How can I get the round value of a number (e.g 4.95, I want to get its closest value of 5), how can I achieve this by MDX?

Thanks a lot and I am looking forward to hearing from you.

With best regards,

Yours sincerely,

go to menu report -> report properties and select code. then paste following code there.

Public Function Round(d as double) AS Double
Dim roundValue AS Double
roundValue =System.Math.Round(d)

If (System.Math.Abs(d - roundValue) - 0.5>0) Then
If (roundValue Mod 2) = 0 Then
roundValue = roundValue + 1
End If
End If

RETURN roundValue
End Function

then in ur designer

Code.Round(Field!Amount.value)

think this wil b ok
|||

Hi, thanks for your help. But i dont understand as what i am trying to do is for the KPI in cube designer, i want to get a round value for the KPI.

Thanks.

With best regards,

Yours sincerely,

|||

Helen,

In MDX you can achieve Rounding by using VBA!Round Function as following

WITH MEMBER [Measures].[My Rounded Measure]

AS VBA!ROUND([Measures].[My Measure],0)

SELECT

{

[Measures].[My Rounded Measure]

} ON 0,

NON EMPTY{

[Customer].[Customer].[Customer]

} ON 1

FROM [My Cube]

Bhudev

No comments:

Post a Comment