Class ModelMeasure (Excel VBA)

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


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

Dim mme as ModelMeasure
Set mme = ActiveWorkbook.Model.ModelMeasures(Index:=1)

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

For Each

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

Dim mme As ModelMeasure
For Each mme In ActiveWorkbook.Model.ModelMeasures
Next mme


ActiveWorkbook.Model.ModelMeasures(1).AssociatedTable =


Deletes the model measure from the data model.



The description of the model measure.

ActiveWorkbook.Model.ModelMeasures(1).Description =


The format of the model measure.

The formatting of the model measure can be of type:

ActiveWorkbook.Model.ModelMeasures(1).FormatInformation =


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

ActiveWorkbook.Model.ModelMeasures(1).Formula =


The name of the model measure.

ActiveWorkbook.Model.ModelMeasures(1).Name =


Adds a model measure to the model.

The formatting of the model measure can be of type:

Add (MeasureName, AssociatedTable, Formula, FormatInformation, Description)

Dim strMeasureName As String: strMeasureName = 
Dim strFormula As String: strFormula = 
Dim mme As ModelMeasure
Set mme = ActiveWorkbook.Model.ModelMeasures.Add(MeasureName:=strMeasureName, AssociatedTable:=, Formula:=strFormula, FormatInformation:=)


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 - The formatting of the model measure. See Remarks

Optional arguments

The following argument is optional

Description - The description associated with the model measure


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

Dim lngCount As Long
lngCount = ActiveWorkbook.Model.ModelMeasures.Count


Returns a single object from a collection.

Item (Index)

Index: The name or index number of the object.

Dim mme As ModelMeasure
Set mme = ActiveWorkbook.Model.ModelMeasures(Index:=1)