Class ModelMeasures (Excel VBA)

The class ModelMeasures represents a collection of ModelMeasure objects. To use a ModelMeasures class variable it first needs to be instantiated, for example


Dim mms as ModelMeasures
Set mms = ActiveWorkbook.Model.ModelMeasures

For Each

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


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

Add

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:=)

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.

Optional arguments

The following argument is optional

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

Count

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


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

Item

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)