Forum Discussion

khampton's avatar
khampton
Frequent Visitor
2 years ago
Solved

DATEADD Function not working when using date heirarchy

I have just moved an SSAS tabular model with a live connection to PBI to directly importing the tables into PBI however the past year calculations do not seem to be working since I changed them over.

I'm using the following measures:

 

Revenue = SUM('Table1'[Revenue])

Prev Year = CALCULATE([Revenue], DATEADD('Date'[Date], -1, YEAR))
As per the screenshot below, this works when I use the date field in a chart. 

 

However when using a different field in the date table or even switching to the date hierarchy, this returns blanks.

 

Any ideas?

  • khampton 

    Did you mark your date table as the date table in your model?

    If the Date table is not marked as the date table, time intelligence functions like DATEADD fail if you are looking at any field besides the date field.

    It's because the model does not understand that Year / Quarter / Month columns are related to the Date[Date] column for use in time intelligence.

    Once you mark it as a date table and identify the date column, all the other columns in the date table will also work for time intelligence functions.

2 Replies

  • khampton 

    Did you mark your date table as the date table in your model?

    If the Date table is not marked as the date table, time intelligence functions like DATEADD fail if you are looking at any field besides the date field.

    It's because the model does not understand that Year / Quarter / Month columns are related to the Date[Date] column for use in time intelligence.

    Once you mark it as a date table and identify the date column, all the other columns in the date table will also work for time intelligence functions.

    • khampton's avatar
      khampton
      Frequent Visitor

      Always an oversight somewhere, thank you!