By: Siddharth Mehta
Overview
No language is complete without one of the most basic and important area of BI functions - Date and Time Intelligence functions. Almost all the formulas and functions we have discussed so far are evaluated in the scope of some time frame in any standard BI reporting application. DAX has Date functions as well as Time Intelligence functions. We will briefly cover some of the important date and time functions in this chapter.
Explanation
Below are a list of some of the frequently used date and time intelligence functions that can be used in DAX expressions.
DATEADD, DATEDIFF - These functions were introduced with SQL Server 2016. These functions can be used to calculate the total or difference between two time periods.
PARALLELPERIOD - This is one of the most popular time intelligence functions. It returns a table that contains a column of dates that represents a period parallel to the dates in the specified dates column, in the current context, with the dates shifted a number of intervals either forward in time or back in time.
SAMEPERIODLASTYEAR - This function returns a table that contains a column of dates shifted one year back in time from the dates in the specified dates column, in the current context.
TOTALQTD, TOTALYTD, TOTALMTD - These functions are very useful while working with month to date, quarter to date and year to date calculations.
CALENDAR - This function has been introduced with SQL Server 2016. This function returns a table with a single column named "Date" that contains 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.
Additional Information
Consider exploring all the different Date functions and Time Intelligence functions available in DAX.