Forum Discussion
DateAdd error
- 8 years ago
Hi ilcaa72
The DATEADD function returns a table of dates, rather than a single date as a scalar value.
The table will contain dates from the visual's filter context shifted by the specified interval (but limited to dates that are present in the date column of the underlying table).
Also DATEADD won't automatically convert a single value to a scalar, which is why you are getting that error message.
A more appropriate measure might be something like:
= EDATE ( MAX ( 'Date tbl'[Date] ), -6 * 12 )
(will return dates not present in 'Date tbl')
or
= LASTDATE ( DATEADD ( 'Date tbl'[Date], -6, YEAR ) )
(will be limited to dates present in 'Date tbl')
Hi ilcaa72
The DATEADD function returns a table of dates, rather than a single date as a scalar value.
The table will contain dates from the visual's filter context shifted by the specified interval (but limited to dates that are present in the date column of the underlying table).
Also DATEADD won't automatically convert a single value to a scalar, which is why you are getting that error message.
A more appropriate measure might be something like:
= EDATE ( MAX ( 'Date tbl'[Date] ), -6 * 12 )
(will return dates not present in 'Date tbl')
or
= LASTDATE ( DATEADD ( 'Date tbl'[Date], -6, YEAR ) )
(will be limited to dates present in 'Date tbl')