Table of Contents

Class Function

Inheritance
Function
Implements
Inherited Members
Namespace
TabularEditor.TOMWrapper
Assembly
TOMWrapper.dll

Represents a user-defined function.

public sealed class Function : TabularNamedObject, ICustomTypeDescriptor, INotifyPropertyChanging, IComparable, IHideableObject, ITomErrorMessageObject, IDescriptionObject, ILineageTagObject, IAnnotationObject, IChangedPropertiesObject, IExtendedPropertyObject, IClonableObject, IDaxDependantObject, IExpressionObject, IDaxObject, ITabularNamedObject, ITabularObject, INotifyPropertyChanged, IHandlerObject, INamedObject
Extension Methods

Remarks

This metadata object is only supported when the compatibility level of the database is at 1702 or above.

Properties

Annotations

The collection of Annotations on the current Function.

[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

DaxObjectFullName

Gets a valid DAX reference to this function

public string DaxObjectFullName { get; }

Property Value

Type Description
string

DaxObjectName

Gets a valid DAX reference to this function

public string DaxObjectName { 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 user-defined function, 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

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 SyntaxError.

public string ErrorMessage { get; }

Property Value

Type Description
string

Expression

The DAX function parameters and expression.

public string Expression { get; set; }

Property Value

Type Description
string

ExtendedProperties

The collection of Extended Properties on the current Function.

public ExtendedPropertyCollection ExtendedProperties { get; }

Property Value

Type Description
ExtendedPropertyCollection

IsHidden

A boolean value that indicates whether the function is treated as hidden by client visualization tools. True if the function is treated as hidden by client visualization tools; otherwise false.

public bool IsHidden { get; set; }

Property Value

Type Description
bool

IsVisible

Gets the visibility of the User-Defined Function.

[Browsable(false)]
public bool IsVisible { get; }

Property Value

Type Description
bool

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.

Parent

The parent Model of the current Function.

public Model Parent { get; }

Property Value

Type Description
Model

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

State

Provides information on the state of the function. Possible values and their interpretation are as follows. Ready (1) The Function is usable. SemanticError (5) The function expression has a semantic error. SyntaxError (9) The function has a syntax error in its expression. All other values are not applicable to Function.

public ObjectState State { get; }

Property Value

Type Description
ObjectState

Methods

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)

Creates an exact copy of this Function object.

public Function Clone(string newName = null)

Parameters

Type Name Description
string newName

Returns

Type Description
Function

CreateNew(Model, string)

Creates a new Function and adds it to the parent Model. Also creates the underlying metadataobject and adds it to the TOM tree.

public static Function CreateNew(Model parent, string name = null)

Parameters

Type Name Description
Model parent
string name

Returns

Type Description
Function

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 Function.

public IEnumerable<string> GetAnnotations()

Returns

Type Description
IEnumerable<string>

GetAnnotationsCount()

Gets the number of annotations on the current Function.

public int GetAnnotationsCount()

Returns

Type Description
int

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

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

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