Forum Discussion

ilcaa72's avatar
ilcaa72
Helper IV
8 years ago
Solved

DateAdd error

enclosed is a screenshot...   not sure what is happening, error doesnt make sense to me.  i want to the date six year ago, let me know what you see or what the requirements are to use DATEADD ...
  • OwenAuger's avatar
    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')