Class Measure
- Inheritance
-
Measure
- Implements
- Inherited Members
- Namespace
- TabularEditor.TOMWrapper
- Assembly
- TOMWrapper.dll
Represents a value that is calculated based on an expression. It is a child of a Table object.
public sealed class Measure : TabularNamedObject, ICustomTypeDescriptor, INotifyPropertyChanging, IComparable, IFolderObject, ITabularTableObject, ITomErrorMessageObject, IDescriptionObject, IFormattableObject, ILineageTagObject, IChangedPropertiesObject, IExtendedPropertyObject, ITabularPerspectiveObject, IHideableObject, ITranslatableObject, IAnnotationObject, ISynonymObject, IClonableObject, IDaxObject, ITabularObjectContainer, IDaxDependantObject, IExpressionObject, ITabularNamedObject, ITabularObject, INotifyPropertyChanged, IHandlerObject, INamedObject
- Extension Methods
Properties
Annotations
The collection of Annotations on the current Measure.
[Browsable(true)]
public AnnotationCollection Annotations { get; }
Property Value
| Type | Description |
|---|---|
| AnnotationCollection |
ChangedProperties
Gets or sets a comma-separated list of names of properties that should no longer be synchronized from the source.
[Browsable(false)]
public string ChangedProperties { get; set; }
Property Value
| Type | Description |
|---|---|
| string |
DataCategory
Specifies the type of data contained in the measure so that you can add custom behaviors based on measure type.
public string DataCategory { get; set; }
Property Value
| Type | Description |
|---|---|
| string |
Remarks
This property is only supported when the compatibility level of the database is at 1455 or above.
DataType
Describes the type of data contained in the column. Possible values are as follows. String (2). Int64 (6). Double (8). DateTime (9). Decimal (10). Boolean (11). Binary (17). Unknown (19) A measure in an error state. Variant (20) A measure with varying data type.
[TypeConverter(typeof(DataTypeEnumConverter))]
public DataType DataType { get; }
Property Value
| Type | Description |
|---|---|
| DataType |
DaxObjectFullName
Gets a valid DAX reference to this measure
[Browsable(true)]
public string DaxObjectFullName { get; }
Property Value
| Type | Description |
|---|---|
| string |
DaxObjectName
Gets a valid DAX reference to this measure
[Browsable(false)]
public string DaxObjectName { get; }
Property Value
| Type | Description |
|---|---|
| string |
DaxTableName
Gets a valid DAX reference to the table on which this measure resides
[Browsable(false)]
public string DaxTableName { get; }
Property Value
| Type | Description |
|---|---|
| string |
DependsOn
Gets the list of objects that this measure depends on.
[Browsable(false)]
public DependsOnList DependsOn { get; }
Property Value
| Type | Description |
|---|---|
| DependsOnList |
Description
The description of the measure, visible to developers at design time and to administrators in management tools, such as SQL Server Management Studio.
public string Description { get; set; }
Property Value
| Type | Description |
|---|---|
| string |
DetailRowsExpression
A DAX expression specifying detail rows for this measure (drill-through in client tools).
public string DetailRowsExpression { get; set; }
Property Value
| Type | Description |
|---|---|
| string |
DisplayFolder
Defines the display folder for the Measure, for use by clients.
public string DisplayFolder { get; set; }
Property Value
| Type | Description |
|---|---|
| string |
ErrorMessage
A string that explains the error state associated with the current object. It is set by the engine only when the state of the object is one of these three values: SemanticError, DependencyError, or EvaluationError. It is applicable only to columns of the type Calculated or CalculatedTableColumn. It will be empty for other column objects.
public string ErrorMessage { get; }
Property Value
| Type | Description |
|---|---|
| string |
Expression
The DAX expression that is evaluated for the calculated measure.
public string Expression { get; set; }
Property Value
| Type | Description |
|---|---|
| string |
ExtendedProperties
The collection of Extended Properties on the current Measure.
public ExtendedPropertyCollection ExtendedProperties { get; }
Property Value
| Type | Description |
|---|---|
| ExtendedPropertyCollection |
FormatString
A string that specifies the format of the measure contents.
[TypeConverter(typeof(FormatStringConverter))]
public string FormatString { get; set; }
Property Value
| Type | Description |
|---|---|
| string |
FormatStringExpression
DAX expression that specifies the format of the cell content.
public string FormatStringExpression { get; set; }
Property Value
| Type | Description |
|---|---|
| string |
InPerspective
[Browsable(true)]
public PerspectiveMeasureIndexer InPerspective { get; }
Property Value
| Type | Description |
|---|---|
| PerspectiveMeasureIndexer |
IsHidden
A boolean value that indicates whether the measure is treated as hidden by client visualization tools. True if the measure is treated as hidden by client visualization tools; otherwise false.
public bool IsHidden { get; set; }
Property Value
| Type | Description |
|---|---|
| bool |
IsSimpleMeasure
A boolean value that indicates whether the measure is an implicit measure that is automatically created by client tools to aggregate a field. Client applications can hide measures that have this flag set.
[Browsable(false)]
public bool IsSimpleMeasure { get; set; }
Property Value
| Type | Description |
|---|---|
| bool |
IsVisible
Gets the visibility of the Measure. Takes into consideration that a measure is visible regardless of its parent table being visible.
[Browsable(false)]
public bool IsVisible { get; }
Property Value
| Type | Description |
|---|---|
| bool |
KPI
Gets or sets the KPI of the Measure.
public KPI KPI { get; set; }
Property Value
| Type | Description |
|---|---|
| KPI |
LineageTag
A tag that represents the lineage of the object.
public string LineageTag { get; set; }
Property Value
| Type | Description |
|---|---|
| string |
Remarks
Lineage tags enable stable identification of objects across different semantic models. Using lineage tags enables Power BI features such as composite models to maintain their binding to referenced tables or columns, even if the source semantic model object is renamed.
This property is only supported when the compatibility level of the database is at 1540 or above.
Parent
The parent Table of the current Measure.
public Table Parent { get; }
Property Value
| Type | Description |
|---|---|
| Table |
ReferencedBy
Gets the list of objects that reference this measure.
[Browsable(false)]
public ReferencedByList ReferencedBy { get; }
Property Value
| Type | Description |
|---|---|
| ReferencedByList |
SourceLineageTag
A tag that represents the lineage of the source for the object.
public string SourceLineageTag { get; set; }
Property Value
| Type | Description |
|---|---|
| string |
Remarks
This property is only supported when the compatibility level of the database is at 1550 or above.
State
Provides information on the state of the measure. Possible values and their interpretation are as follows. Ready (1) The measure is queryable and has up-to-date data. NoData (3) Not applicable to Measure. CalculationNeeded (4) Not applicable to Measure. SemanticError (5) The measure expression has a semantic error. EvaluationError (6) Not applicable to Measure. DependencyError (7) A dependency associated with this measure is in an error state (SemanticError, EvaluationError, or DependencyError). Incomplete (8) Not applicable to Measure. SyntaxError (9) The measure has a syntax error in its expression.
public ObjectState State { get; }
Property Value
| Type | Description |
|---|---|
| ObjectState |
Synonyms
Collection of localized synonyms for this Measure.
[Browsable(true)]
public SynonymIndexer Synonyms { get; }
Property Value
| Type | Description |
|---|---|
| SynonymIndexer |
Table
The parent table of the current Measure.
[Browsable(false)]
public Table Table { get; }
Property Value
| Type | Description |
|---|---|
| Table |
TranslatedDescriptions
Collection of localized descriptions for this Measure.
[Browsable(true)]
public TranslationIndexer TranslatedDescriptions { get; }
Property Value
| Type | Description |
|---|---|
| TranslationIndexer |
TranslatedDisplayFolders
Collection of localized Display Folders for the current Measure.
[Browsable(true)]
public TranslationIndexer TranslatedDisplayFolders { get; }
Property Value
| Type | Description |
|---|---|
| TranslationIndexer |
TranslatedNames
Collection of localized names for this Measure.
[Browsable(true)]
public TranslationIndexer TranslatedNames { get; }
Property Value
| Type | Description |
|---|---|
| TranslationIndexer |
Methods
AddKPI()
Adds a KPI to this measure.
public KPI AddKPI()
Returns
| Type | Description |
|---|---|
| KPI |
AllowDelete(out string)
Derived classes should override this method to prevent an object from being deleted. If left un-overridden, always returns TRUE and sets message to null.
protected override bool AllowDelete(out string message)
Parameters
| Type | Name | Description |
|---|---|---|
| string | message | If an object CANNOT be deleted, this string should provide a reason why. If an object CAN be deleted, this string may optionally provide a suitable warning message that applies if the object is deleted immediately after the call to CanDelete. |
Returns
| Type | Description |
|---|---|
| bool | True if an object can be deleted. False otherwise. |
ClearAnnotations()
Removes all annotations from this object.
public void ClearAnnotations()
ClearChangedProperties()
Clears the list of names of changed properties.
public void ClearChangedProperties()
ClearExtendedProperties()
Removes all Extended Properties from this object.
public void ClearExtendedProperties()
Clone(string, bool, Table)
Creates an exact copy of this Measure object.
public Measure Clone(string newName = null, bool includeTranslations = true, Table newParent = null)
Parameters
| Type | Name | Description |
|---|---|---|
| string | newName | |
| bool | includeTranslations | |
| Table | newParent |
Returns
| Type | Description |
|---|---|
| Measure |
CreateNew(Table, string)
Creates a new Measure and adds it to the parent Table. Also creates the underlying metadataobject and adds it to the TOM tree.
public static Measure CreateNew(Table parent, string name = null)
Parameters
| Type | Name | Description |
|---|---|---|
| Table | parent | |
| string | name |
Returns
| Type | Description |
|---|---|
| Measure |
CustomReinit()
protected override void CustomReinit()
GetAnnotation(int)
Gets the value of the annotation with the given index, assuming it exists.
public string GetAnnotation(int index)
Parameters
| Type | Name | Description |
|---|---|---|
| int | index |
Returns
| Type | Description |
|---|---|
| string |
GetAnnotation(string)
Gets the value of the annotation with the given name. Returns null if no such annotation exists.
public string GetAnnotation(string name)
Parameters
| Type | Name | Description |
|---|---|---|
| string | name |
Returns
| Type | Description |
|---|---|
| string |
GetAnnotations()
Gets a collection of all annotation names on the current Measure.
public IEnumerable<string> GetAnnotations()
Returns
| Type | Description |
|---|---|
| IEnumerable<string> |
GetAnnotationsCount()
Gets the number of annotations on the current Measure.
public int GetAnnotationsCount()
Returns
| Type | Description |
|---|---|
| int |
GetChildren()
public IEnumerable<ITabularNamedObject> GetChildren()
Returns
| Type | Description |
|---|---|
| IEnumerable<ITabularNamedObject> |
GetExtendedProperties()
Gets a collection of all ExtendedProperty names on the current object.
public IEnumerable<string> GetExtendedProperties()
Returns
| Type | Description |
|---|---|
| IEnumerable<string> |
GetExtendedProperty(int)
Gets the value of the ExtendedProperty with the given index, assuming it exists.
public string GetExtendedProperty(int index)
Parameters
| Type | Name | Description |
|---|---|---|
| int | index |
Returns
| Type | Description |
|---|---|
| string |
GetExtendedProperty(string)
Gets the value of the ExtendedProperty with the given name. Returns null if no such ExtendedProperty exists.
public string GetExtendedProperty(string name)
Parameters
| Type | Name | Description |
|---|---|---|
| string | name |
Returns
| Type | Description |
|---|---|
| string |
GetExtendedPropertyCount()
Gets the number of ExtendedProperties on the current object.
public int GetExtendedPropertyCount()
Returns
| Type | Description |
|---|---|
| int |
GetExtendedPropertyType(int)
Gets the type of the ExtendedProperty with the given index, assuming it exists.
public ExtendedPropertyType GetExtendedPropertyType(int index)
Parameters
| Type | Name | Description |
|---|---|---|
| int | index |
Returns
| Type | Description |
|---|---|
| ExtendedPropertyType |
GetExtendedPropertyType(string)
Gets the type of the ExtendedProperty with the given name, assuming it exists.
public ExtendedPropertyType GetExtendedPropertyType(string name)
Parameters
| Type | Name | Description |
|---|---|---|
| string | name |
Returns
| Type | Description |
|---|---|
| ExtendedPropertyType |
GetNewAnnotationName()
Returns a unique name for a new annotation.
public string GetNewAnnotationName()
Returns
| Type | Description |
|---|---|
| string |
GetNewExtendedPropertyName()
Returns a unique name for a new ExtendedProperty.
public string GetNewExtendedPropertyName()
Returns
| Type | Description |
|---|---|
| string |
HasAnnotation(string)
Returns true if an annotation with the given name exists. Otherwise false.
public bool HasAnnotation(string name)
Parameters
| Type | Name | Description |
|---|---|---|
| string | name |
Returns
| Type | Description |
|---|---|
| bool |
HasExtendedProperty(string)
Returns true if an ExtendedProperty with the given name exists. Otherwise false.
public bool HasExtendedProperty(string name)
Parameters
| Type | Name | Description |
|---|---|---|
| string | name |
Returns
| Type | Description |
|---|---|
| bool |
Init()
Derived members should override this method to instantiate child objects
protected override void Init()
MoveTo(string)
Delete the measure from its current table and create a deep clone (including all translations, if any) in the destination table.
public void MoveTo(string destinationTable)
Parameters
| Type | Name | Description |
|---|---|---|
| string | destinationTable |
Exceptions
MoveTo(Table)
Delete the measure from its current table and create a deep clone (including all translations, if any) in the destination table.
public void MoveTo(Table destinationTable)
Parameters
| Type | Name | Description |
|---|---|---|
| Table | destinationTable |
OnPropertyChanged(string, object, object)
Fired after a property is changed
protected override void OnPropertyChanged(string propertyName, object oldValue, object newValue)
Parameters
| Type | Name | Description |
|---|---|---|
| string | propertyName | |
| object | oldValue | |
| object | newValue |
OnPropertyChanging(string, object, ref bool, ref bool)
Called before a property is changed on an object. Derived classes can control how the change is handled. Throw ArgumentException within this method, to display an error message in the UI.
protected override void OnPropertyChanging(string propertyName, object newValue, ref bool undoable, ref bool cancel)
Parameters
| Type | Name | Description |
|---|---|---|
| string | propertyName | Name of the changed property. |
| object | newValue | New value assigned to the property. |
| bool | undoable | Return false if automatic undo of the property change is not needed. |
| bool | cancel | Return true if the property change should not apply. |
RemoveAnnotation(string)
Remove an annotation by the given name.
public void RemoveAnnotation(string name)
Parameters
| Type | Name | Description |
|---|---|---|
| string | name |
RemoveExtendedProperty(string)
Remove an ExtendedProperty by the given name.
public void RemoveExtendedProperty(string name)
Parameters
| Type | Name | Description |
|---|---|---|
| string | name |
RemoveKPI()
Removes the KPI from this measure.
public void RemoveKPI()
SetAnnotation(int, string)
Sets the value of the annotation with the given index, assuming it exists.
public void SetAnnotation(int index, string value)
Parameters
| Type | Name | Description |
|---|---|---|
| int | index | |
| string | value |
SetAnnotation(string, string)
Sets the value of the annotation having the given name. If no such annotation exists, it will be created. If value is set to null, the annotation will be removed.
public void SetAnnotation(string name, string value)
Parameters
| Type | Name | Description |
|---|---|---|
| string | name | |
| string | value |
SetExtendedProperty(int, string, ExtendedPropertyType)
Sets the value of the ExtendedProperty with the given index, optionally specifiying the type (string or JSON) of the ExtendedProperty.
public void SetExtendedProperty(int index, string value, ExtendedPropertyType type)
Parameters
| Type | Name | Description |
|---|---|---|
| int | index | |
| string | value | |
| ExtendedPropertyType | type |
SetExtendedProperty(string, string, ExtendedPropertyType)
Sets the value of the ExtendedProperty having the given name. If no such ExtendedProperty exists, it will be created. If value is set to null, the ExtendedProperty will be removed.
public void SetExtendedProperty(string name, string value, ExtendedPropertyType type)
Parameters
| Type | Name | Description |
|---|---|---|
| string | name | |
| string | value | |
| ExtendedPropertyType | type |
ShouldSerializeDetailRowsExpression()
public bool ShouldSerializeDetailRowsExpression()
Returns
| Type | Description |
|---|---|
| bool |