Table of Contents

Class Calendar

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

Defines a logical calendar as part of the DAX Time-Intelligence support.

public sealed class Calendar : TabularNamedObject, ICustomTypeDescriptor, INotifyPropertyChanging, IComparable, ITabularTableObject, ITabularObjectContainerObject, IDescriptionObject, ILineageTagObject, IClonableObject, IDaxObject, ITabularNamedObject, ITabularObject, INotifyPropertyChanged, IHandlerObject, INamedObject
Extension Methods

Remarks

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

Properties

CalendarColumnGroups

The collection of CalendarColumnGroup objects on this Calendar.

public CalendarColumnGroupCollection CalendarColumnGroups { get; }

Property Value

Type Description
CalendarColumnGroupCollection

ColumnMappings

The collection of column mappings that define the calendar's time unit associations. This is an alias for CalendarColumnGroups.

public CalendarColumnGroupCollection ColumnMappings { get; }

Property Value

Type Description
CalendarColumnGroupCollection

DaxObjectFullName

Gets a string that may be used for referencing the caæemdar in a DAX expression.

[Browsable(false)]
public string DaxObjectFullName { get; }

Property Value

Type Description
string

DaxObjectName

Gets a string that may be used for referencing the calendar in a DAX expression.

[Browsable(false)]
public string DaxObjectName { get; }

Property Value

Type Description
string

DaxTableName

Gets a string that may be used for referencing the calendar in a DAX expression.

[Browsable(false)]
public string DaxTableName { get; }

Property Value

Type Description
string

Description

The description of the Calendar, 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

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 Table of the current Calendar.

public Table Parent { get; }

Property Value

Type Description
Table

ReferencedBy

Gets the list of objects that reference this calendar based on their DAX expressions.

[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

Table

The parent table of the current Calendar.

[Browsable(false)]
public Table Table { get; }

Property Value

Type Description
Table

Methods

AddTimeRelatedColumn(Column)

Adds a column to a time-related column group. If no groups exist, creates a new one. If multiple groups exist, adds to the first group.

public TimeRelatedColumnGroup AddTimeRelatedColumn(Column column)

Parameters

Type Name Description
Column column

The column to add

Returns

Type Description
TimeRelatedColumnGroup

The TimeRelatedColumnGroup that contains the added column

Exceptions

ArgumentNullException

Thrown when column is null

ArgumentException

Thrown when column does not belong to the same table as the calendar

AddTimeRelatedColumnGroup()

Adds a new time-related column group to the calendar.

public TimeRelatedColumnGroup AddTimeRelatedColumnGroup()

Returns

Type Description
TimeRelatedColumnGroup

The newly created TimeRelatedColumnGroup

AddTimeUnit(TimeUnit, Column, params Column[])

Adds a new time unit association to the calendar.

public TimeUnitColumnAssociation AddTimeUnit(TimeUnit timeUnit, Column primaryColumn, params Column[] associatedColumns)

Parameters

Type Name Description
TimeUnit timeUnit

The unit of time

Column primaryColumn

The primary column to associate with this time unit

Column[] associatedColumns

Additional associated columns (i.e. columns representing the same time unit as the primary column in other formats, languages, etc.)

Returns

Type Description
TimeUnitColumnAssociation

Exceptions

ArgumentNullException
ArgumentException

Clone(string, Table)

Creates an exact copy of this Calendar object.

public Calendar Clone(string newName = null, Table newParent = null)

Parameters

Type Name Description
string newName
Table newParent

Returns

Type Description
Calendar

CreateNew(Table, string)

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

public static Calendar CreateNew(Table parent, string name = null)

Parameters

Type Name Description
Table parent
string name

Returns

Type Description
Calendar

DeleteTimeRelatedColumnGroup(TimeRelatedColumnGroup)

Removes the specified time-related column group from the calendar.

public bool DeleteTimeRelatedColumnGroup(TimeRelatedColumnGroup group)

Parameters

Type Name Description
TimeRelatedColumnGroup group

The TimeRelatedColumnGroup to remove

Returns

Type Description
bool

True if the group was found and removed; otherwise, false

Exceptions

ArgumentNullException

Thrown when group is null

DeleteTimeUnit(TimeUnit)

Removes the specified time unit association from the calendar.

public bool DeleteTimeUnit(TimeUnit timeUnit)

Parameters

Type Name Description
TimeUnit timeUnit

Returns

Type Description
bool

FindTimeUnit(TimeUnit)

Finds the time unit association for the specified time unit. Returns null if no association exists for the specified time unit.

public TimeUnitColumnAssociation FindTimeUnit(TimeUnit timeUnit)

Parameters

Type Name Description
TimeUnit timeUnit

Returns

Type Description
TimeUnitColumnAssociation

GetAllTimeRelatedColumns()

Gets all time-related columns across all time-related column groups in this calendar.

public IEnumerable<Column> GetAllTimeRelatedColumns()

Returns

Type Description
IEnumerable<Column>

An enumerable collection of all time-related columns

GetTimeRelatedColumnGroups()

Returns all time-related column groups in the calendar.

public IEnumerable<TimeRelatedColumnGroup> GetTimeRelatedColumnGroups()

Returns

Type Description
IEnumerable<TimeRelatedColumnGroup>

An enumerable collection of TimeRelatedColumnGroup objects

GetTimeUnitForColumn(Column)

Gets the time unit mapping for the specified column. Returns TabularEditor.TOMWrapper.TimeUnit.Unknown if the column is not mapped to any time units.

public TimeUnit GetTimeUnitForColumn(Column column)

Parameters

Type Name Description
Column column

Returns

Type Description
TimeUnit

GetTimeUnits()

Returns all time unit associations in the calendar.

public IEnumerable<TimeUnitColumnAssociation> GetTimeUnits()

Returns

Type Description
IEnumerable<TimeUnitColumnAssociation>

IsTimeRelatedColumn(Column)

Checks if a column is part of any time-related column group in this calendar.

public bool IsTimeRelatedColumn(Column column)

Parameters

Type Name Description
Column column

The column to check

Returns

Type Description
bool

True if the column is in a time-related column group; otherwise, false

MoveTo(string)

Moves this calendar to a different table by name.

public void MoveTo(string destinationTableName)

Parameters

Type Name Description
string destinationTableName

The name of the table to move this calendar to

Exceptions

InvalidOperationException

Thrown when the table is not found

MoveTo(Table)

Moves this calendar to a different table by deleting it and recreating it on the target table. All time unit mappings, associated columns, and time-related columns are cleared because columns typically differ between tables.

public void MoveTo(Table destinationTable)

Parameters

Type Name Description
Table destinationTable

The table to move this calendar to

Exceptions

ArgumentNullException

Thrown when destinationTable is null

InvalidOperationException

Thrown when attempting to move to the same table

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.

RemoveTimeRelatedColumn(Column)

Removes a column from all time-related column groups in the calendar.

public bool RemoveTimeRelatedColumn(Column column)

Parameters

Type Name Description
Column column

The column to remove

Returns

Type Description
bool

True if the column was found and removed from at least one group; otherwise, false

Exceptions

ArgumentNullException

Thrown when column is null