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.
Siddharth has more than 14 years of experience in the IT Industry, with more than a decade of experience in Business Intelligence and Analytics, for clients banking, logistics, government, Media Entertainment, products, life sciences and other domains. He has been a lead architect for a portfolio of 40+ apps, containing apps in web, mobile, BI, Analytics, data warehousing, reporting, collaboration, CMS, NoSQL and other technologies. He has several certifications and is a published author for online and print-media publications, as well as the MSDN Library.
In his present role, he remains responsible for architecture design, technology stack selection, infrastructure design, 3rd party products evaluation and procurement, and performance engineering. These applications use technologies like Elasticsearch / Lucene, MongoDB, SharePoint 2013 and 2010, jQuery-based framework like Highcharts and GoJS, SQL Server and the Microsoft Business Intelligence stack (SSIS, SSAS, SSRS, MDX, PowerPivot, PowerView), jQueryMobile, Bootstrap, iOS xCode framework, and many others.
- MSSQLTips Awards: Champion (100+ tips) – 2018 | Author of the Year – 2017 | Author Contender – 2016, 2018-2019

