CALENDAR DAX Function (Date and Time)

Returns a table with one column of all dates between StartDate and EndDate.

Syntax

CALENDAR ( <StartDate>, <EndDate> )
Parameter Attributes Description
StartDate

The start date in datetime format.

EndDate

The end date in datetime format.

Return values

Table A table with a single column.

Returns a table with a single column named “Date” containing a contiguous set of dates. The range of dates is from the specified start date to the specified end date, inclusive of those two dates.

Remarks

The CALENDAR table is useful to create a Date table.
For compatibility with DAX time intelligence functions, it is a best practice to always include an entire year in a Date table.

Examples

The following formula returns a table with dates between January 1st, 2005 and December 31st, 2015.

CALENDAR (
    DATE ( 2005, 1, 1 ), 
    DATE ( 2015, 12, 31 )
)

The following expression returns the date table covering the range of dates in actual sales data and future sales forecasts.

CALENDAR (
    DATE ( YEAR ( MIN ( [Date] ) ), 1, 1 ),
    DATE ( YEAR ( MAX ( Forecast ) ), 12, 31 )
)

Because a date column can be represented as an integer, CALENDAR can be used as a way to obtain a result similar to a particular call to GENERATESERIES. For example, the following expressions are equivalent, even if the former produces a table with a DateTime data type, whereas the latter returns a table with an Integer data type.

CALENDAR ( 1, 100 )

GENERATESERIES ( 1, 100, 1 )

Related articles

Learn more about CALENDAR in the following articles:

  • Reference Date Table in DAX and Power BI

    This article describes a reference Date table in DAX using a Power BI template. The same technique can be used in Analysis Services models. Download the latest version of the template in the Dax Date Template page. » Read more

Related functions

Other related functions are:

Last update: Dec 1, 2018   » Contribute   » Show contributors

Contributors: Alberto Ferrari, Marco Russo

MSDN documentation: https://msdn.microsoft.com/en-us/query-bi/dax/calendar-function-dax

DAX Conventions
Context Transition

This function performs a Context Transition if called in a Row Context. Click to read more.

Row Context

This expression is executed in a Row Context. Click to read more.

Iterator

Not recommended

The use of this function is not recommended. See Remarks and Related functions for alternatives.

Not recommended

The use of this parameter is not recommended.

Deprecated

This function is deprecated. Jump to the Alternatives section to see the function to use.

Deprecated

This parameter is deprecated and its use is not recommended.

Contribute

Want to improve the content of CALENDAR? Did you find any issue? Please, report it us!
All submissions will be evaluated for possible updates of the content.