Forum Discussion
SAMEPERIODLASTYEAR(DATESYTD( )) different from DATESYTD(SAMEPERIODLASTYEAR( ))??
- 7 years ago
This is just another case where the Time Intelligence functions don't work as expected because the Date table is wrong.
Remember: Time Intelligence functions are guaranteed to work *only* if the Date table is "complete" - meaning you need all the dates until the end of the year.
Not doing that, what happens is that the year 2019 seems made by 15 days, so if you include all of them than it seems you have an entire month, or an entire year.... You are violating the assumption made by Time Intelligence and you cannot trust any result at that point.
- AlB7 years ago
Community Champion
Hi v-lili6-msft
Thanks very much. I look forward to hearing from them.
- AlB7 years ago
Community Champion
Perhaps very knowledgeable people like Zubair_Muhammad, Greg_Deckler, MFelix would care to chip in?
Many thanks
- Zubair_Muhammad7 years ago
Community Champion
Very interesting
I remember you found a bug before as well :smileywink:
I am not sure why this is happeningbut if we use following we get correct results even with the last date.
YTDPreviousYearRevenue = CALCULATE ( SUM ( Revenue[Revenue] ), SAMEPERIODLASTYEAR ( DATESYTD ( 'Date Table'[Date].[Date]) ) )
- AlB7 years ago
Community Champion
- v-lili6-msft7 years ago
Community Support
hi, AlB
Unfortunately, So far I haven't got any reply about this question.
and I read these in the book The Definitive Guide to DAX: Business intelligence with Microsoft Excel, SQL Server Analysis Services, and Power BI by Marco Russo and Alberto Ferrari.
in page 173:
The following two definitions of PY YTD Sales are equivalent, even if the second one could be slightly faster (but barely measureable).
and in your case, date table is from "2018,1,1" to today, you may try this formula
Date Table = ADDCOLUMNS ( CALENDAR (DATE(2018,1,1), DATE(YEAR(TODAY()),12,31)), "Year", YEAR ( [Date]), "Month Name", FORMAT ( [Date], "mmmm" ), "Monthnumber", FORMAT ( [Date], "MM" ) )add a judge column for date table
judge = IF('Date Table'[Date]<=TODAY(),1,2)Then add it to report level filter and set it "1"
Result:
This is just as a reference, I also think reason for this case is that date table is incomplete.
Best Regards,
Lin