Introduction
In the previous article you can see the different types of DAX functions. I mentioned almost all DAX functions and their categories. So here in this article I will explain about ‘Date and Time Functions’ in Power BI and their syntaxes.
I mentioned 19 ‘Date & Time’ functions in my previous article so let's see what are these functions, their description and their DAX formula syntaxes.
Description
CALENDAR
Return a single column table, default column name is ‘Date’.
Syntax- CALENDAR(<StartDate>, <EndDate>)
<StartDate> and <EndDate> should be any DAX expression that returns Datetime value.
Ex- CALENDAR(DATE(2019,8,1), DATE(2020,3,1)).

CALENDARAUTO
Returns a table with one column of dates calculated from the model automatically.
Syntax- CALENDARAUTO([FiscalYearEndMonth])
<FiscalYearEndMonth>Any DAX expression that returns an integer from 1 to 12. If you mention the number then it will start from that number to 12 by default. If omitted then it will start from minimum value to maximum value in calendar table of current user.
Ex- If min and max date of data model are May-01-2019 and June-30-2020 respectively then:
CALENDARAUTO()- returns all dates from Jan-01-2019 to Dec-31-2020
CALENDARAUTO(3)- returns dates from Mar-01-2019 to Feb-28-2021.
The below image represents the current user data:

YEAR
Returns a 4 digit year value from the date.
Syntax- YEAR(Date)
Date- A date of ‘datetime’ datatype or text
Ex- YEAR(“June 1990”) or YEAR(TODAY())

YEARFRAC
Returns the year fraction representing the number of whole days between start date and end date. IT returns a decimal number.
Syntax- YEARFRAC(StartDate,EndDate,[Basic])
[Basic]- (Optional) The type of day count basis to use. All arguments are truncated to integers. Limit- 0 to 4.
If Basic is <0 or >4 then it will return error.
Basic 0 - US (NASD) 30/360
Basic 1 - Actual/actual
Basic 2 - Actual/360
Basic 3 - Actual/365
Basic 4 - European 30/360

Month








Join the conversation! Your thoughts help the community grow.