Class ModelMeasure (Excel VBA)

The class ModelMeasure represents a single ModelMeasure object in the ModelMeasures collection.

Set

To use a ModelMeasure class variable it first needs to be instantiated, for example

Dim strMeasureName As String: strMeasureName = 
Dim mdltAssociatedTable As ModelTable: Set mdltAssociatedTable = 
Dim strFormula As String: strFormula = 
Dim mdlFormatInformation As Model: Set mdlFormatInformation = 
Dim mdl As Model: Set mdl = 
Dim mme As ModelMeasure
Set mme = mdl.ModelMeasures.Add(MeasureName:=strMeasureName, AssociatedTable:=mdltAssociatedTable, Formula:=strFormula, FormatInformation:=mdlFormatInformation, Description:="")

The following procedures can be used to set variables of type ModelMeasure: ModelMeasures.Item, ModelMeasures.Add and Model.ModelMeasures

For Each

Here is an example of processing the ModelMeasure items in a collection.

Dim mdl As Model: Set mdl = 
Dim mmeModelMeasure As ModelMeasure
For Each mmeModelMeasure In mdl.ModelMeasures
	
Next mmeModelMeasure

Delete

Deletes the model measure from the data model.

Description

The description of the model measure.

FormatInformation

The format of the model measure.

The formatting of the model measure can be of type:

Formula

The Data Analysis Expressions (DAX) formula of the model measure.

Name

The name of the model measure.

Parent

Returns the parent object for the specified object. Read-only.

ModelMeasures.Add

Adds a model measure to the model.

The formatting of the model measure can be of type:

Syntax : expression.Add (MeasureName, AssociatedTable, Formula, FormatInformation, Description)

Arguments

The following arguments are required:

MeasureName (String) - The name of the model measure.

AssociatedTable (ModelTable) - The model table associated with the model measure. This is the table that contains the model measure, as seen in the Field List task pane.

Formula (String) - The Data Analysis Expressions (DAX) formula, inserted as a string.

FormatInformation (Model) - The formatting of the model measure. See Remarks.

The following argument is optional

Description (String) - The description associated with the model measure.

ModelMeasures.Count

Returns an integer that represents the number of objects in the collection.

ModelMeasures.Item

Returns a single object from a collection.

Syntax : expression.Item (Index)

Index: The name or index number of the object.

ModelMeasures.Parent

Returns the parent object for the specified object. Read-only.