Forum Discussion
DATESYTD function
- 1 year ago
Hi FBergamaschi ,
I realised that I had more than one table marked as date table. For example, I had both the Calendar and CalendarTbl marked as Date tables. As soon as I turned off Calendar as being Date table it worked!
Thank You
Hi mp390988
Why 'Calendar' works:
'Calendar' is a DirectQuery table from another semantic model.
It is already part of the model's relationships, likely connected to your fact table (where [Revenue] is calculated).
DATESYTD('Calendar'[Date]) works because Power BI can trace the relationship and apply the time intelligence function correctly.
Why 'CalendarTbl' does not work:
'CalendarTbl' is a calculated table created using SELECTCOLUMNS from 'Calendar'.
Calculated tables do not automatically inherit relationships from their source tables.
Unless you manually create a relationship between 'CalendarTbl' and your fact table, Power BI cannot resolve the filter context for [Revenue] through 'CalendarTbl'.
DATESYTD() needs a properly related date column to work in a time intelligence context.
If 'CalendarTbl' is not related to your fact table, the filter context created by DATESYTD('CalendarTbl'[Date]) has no effect on [Revenue].
You have a couple of options, in my opinion the first is the best option.
- Use the original 'Calendar' table in your measure.
- Create a relationship between 'CalendarTbl' and your fact table on the [Date] column.
I hope this helps, please give a thumbs up and mark as solved if it does, thanks!