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.
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
Thanks marcorusso and v-lili6-msft