Edit

Share via


CubeFields.GetMeasure(Object, XlConsolidationFunction, Object) Method

Definition

Given an attribute hierarchy, returns an implicit measure for the given function that corresponds to this attribute. If an “implicit measure” does not exist, a new implicit measure is created and added to the CubeFields collection.

public Microsoft.Office.Interop.Excel.CubeField GetMeasure (object AttributeHierarchy, Microsoft.Office.Interop.Excel.XlConsolidationFunction Function, object Caption);
Public Function GetMeasure (AttributeHierarchy As Object, Function As XlConsolidationFunction, Optional Caption As Object) As CubeField

Parameters

AttributeHierarchy
Object

The unique cube field that is an attribute hierarchy (XlCubeFieldType = xlHierarchy and XlCubeFieldSubType = xlCubeAttribute).

Function
XlConsolidationFunction

The function performed in the added data field.

Caption
Object

The label used in the PivotTable report to identify this measure. If the measure already exists, caption will overwrite the existing label of this measure.

Returns

Remarks

Important: Getting a measure by using the GetMeasure function will work for these functions only: Count, Sum, Average, Max and Min. For example:These will workGet CubeField0 = modelPivotTable.CubeFields.GetMeasure("[customer].[num_cars_owned]", xlCount, "NumCarsOwnedCount")Set CubeField1 = modelPivotTable.CubeFields.GetMeasure("[customer].[num_cars_owned]", xlSum, "NumCarsOwnedSum")Set CubeField2 = modelPivotTable.CubeFields.GetMeasure("[customer].[num_cars_owned]", xlAverage, "NumCarsOwnedAverage")Set CubeField4 = modelPivotTable.CubeFields.GetMeasure("[customer].[num_cars_owned]", xlMax, "NumCarsOwnedMax")Set CubeField5 = modelPivotTable.CubeFields.GetMeasure("[customer].[num_cars_owned]", xlMin, "NumCarsOwnedMin")These will not workSet CubeField3 = modelPivotTable.CubeFields.GetMeasure("[customer].[num_cars_owned]", xlCountNums, "NumCarsOwnedCountNums")Set CubeField6 = modelPivotTable.CubeFields.GetMeasure("[customer].[num_cars_owned]", xlProduct, "NumCarsOwnedProduct")Set CubeField7 = modelPivotTable.CubeFields.GetMeasure("[customer].[num_cars_owned]", xlStDev, "NumCarsOwnedStDev")Set CubeField8 = modelPivotTable.CubeFields.GetMeasure("[customer].[num_cars_owned]", xlStDevP, "NumCarsOwnedStDevP")

Applies to