DATEADD Function in
DAX
DATEADD function is used to add days to the specified dates
based on the interval we are specifying.
Syntax:
DATEADD(<DATES>,<No_Of_Intervals>,<Interval>)
Parameters:
Dates: It can be any Date or DateTime Column. It can be an expression
that returns date or datetime value.
No Of Intervals : It is an integer value which specifies the number to be
added or subtracted from the date. If the interval value is positive, it moves
the dates forward in time, and if the interval value is negative it moves the
dates backward in time.
Interval : The interval by which to shift the dates. The value for
interval can be one of the following: year, quarter, month, day. Interval
should not be given without quotes.
Return Values:
A table
containing a single column with dates.
Below
expression will move year backward in the current context.
DATEADD(Orders[Order
Date],-1,YEAR)
This is
useful when we are comparing current year sales with previous year sales.
LY_Sales =
CALCULATE(SUM(Orders[Sales]),DATEADD(DimDate[Date],-1,YEAR))
This comment has been removed by the author.
ReplyDeleteIt’s interesting to read content nice post.
ReplyDeleteMS Power BI Online Training