RadarSoft.RadarCube.Web.MSAS Send comments on this topic.
AddCalculatedMeasure(String,String,String,String,Boolean) Method
See Also  Example
RadarSoft.RadarCube.Web Namespace > TMeasures Class > AddCalculatedMeasure Method : AddCalculatedMeasure(String,String,String,String,Boolean) Method




DisplayName
measure caption
Description
measure description
DisplayFolder
subfolder in Cube Structure tree where the specified measure is to be placed
UniqueName
a unique string identifier
Visible
defines whether the measure will be displayed in the Grid right after its creation
Adds a calculated measure of the third type to the collection of Grid measures.

Syntax

Visual Basic (Declaration) 
Public Overloads Function AddCalculatedMeasure( _
   ByVal DisplayName As String, _
   ByVal Description As String, _
   ByVal DisplayFolder As String, _
   ByVal UniqueName As String, _
   ByVal Visible As Boolean _
) As TMeasure
Visual Basic (Usage)Copy Code
Dim instance As TMeasures
Dim DisplayName As String
Dim Description As String
Dim DisplayFolder As String
Dim UniqueName As String
Dim Visible As Boolean
Dim value As TMeasure
 
value = instance.AddCalculatedMeasure(DisplayName, Description, DisplayFolder, UniqueName, Visible)
C# 
public TMeasure AddCalculatedMeasure( 
   string DisplayName,
   string Description,
   string DisplayFolder,
   string UniqueName,
   bool Visible
)
Managed Extensions for C++ 
public: TMeasure* AddCalculatedMeasure( 
   string* DisplayName,
   string* Description,
   string* DisplayFolder,
   string* UniqueName,
   bool Visible
) 
C++/CLI 
public:
TMeasure^ AddCalculatedMeasure( 
   String^ DisplayName,
   String^ Description,
   String^ DisplayFolder,
   String^ UniqueName,
   bool Visible
) 

Parameters

DisplayName
measure caption
Description
measure description
DisplayFolder
subfolder in Cube Structure tree where the specified measure is to be placed
UniqueName
a unique string identifier
Visible
defines whether the measure will be displayed in the Grid right after its creation

Example

C#Copy Code
private void CalculatingSalesAverage(object sender, TCalcMemberArgs e)
{
    if (e.CurrentAddress.Measure.DisplayName == "Sales Average")
    {
        ICubeAddress a = e.CurrentAddress;
        a.Measure = this.Grid.Measures.FindByDisplayName("Sales Count");
        int v1 = Convert.ToInt32(e.Evaluator.GetValue(a));
        if (v1 == 0)
        {
            e.ReturnData = null;
            e.ReturnValue = "N/A";
        }
        else
        {
            a.Measure = this.Grid.Measures.FindByDisplayName("Warehouse Sales");
            double v2 = Convert.ToDouble(e.Evaluator.GetValue(a));
            if (v2 == 0)
            {
                e.ReturnData = null;
                e.ReturnValue = "N/A";
            }
            else
            {
                e.ReturnData = v2 / ((double) v1);
                e.ReturnValue = e.Evaluator.Format(e.ReturnData, "Currency");
            }
        }
    }
}
Visual BasicCopy Code
Private Sub CalculatingSalesAverage(ByVal sender As Object, ByVal e As TCalcMemberArgs)
    If (e.CurrentAddress.Measure.DisplayName Is "Sales Average") Then
        Dim a As ICubeAddress = e.CurrentAddress
        a.Measure = Me.Grid.Measures.FindByDisplayName("Sales Count")
        Dim v1 As Integer = Convert.ToInt32(e.Evaluator.GetValue(a))
        If (v1 = 0) Then
            e.ReturnData = Nothing
            e.ReturnValue = "N/A"
        Else
            a.Measure = Me.Grid.Measures.FindByDisplayName("Warehouse Sales")
            Dim v2 As Double = Convert.ToDouble(e.Evaluator.GetValue(a))
            If (v2 = 0) Then
                e.ReturnData = Nothing
                e.ReturnValue = "N/A"
            Else
                e.ReturnData = (v2 / CDbl(v1))
                e.ReturnValue = e.Evaluator.Format(e.ReturnData, "Currency")
            End If
        End If
    End If
End Sub

Remarks

MSAS version supports two ways of calculating measures, added by this method:

  • With an MDX expression (if an MDX formula for calculating measure is specified by the TMeasure.Expression property).
  • With the TOLAPGrid.OnCalcMember event handler (if the Expression property for this measure is not specified)

The Direct version supports only the latter.

Requirements

Target Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, Windows Vista, Windows Server 2008 family

See Also

© 2010 Radar-Soft, L.L.C. All Rights Reserved.