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.
AlB v-lili6-msft marcorusso Greg_Deckler MFelix
I am encountering a similiar problem with my data set at the moment, and both of the formulas (attached) here are resulting a value that is until end of month, rather than (ie today up to 08/05/19). I am not sure if the reason for this is that i am using a relationship to connect my data table to a calendar table, as my data is not contiguous, so results in an error when a date slicer is used...
I am using
and i am getting the correct result, however it is quite ugly and seems to have some bugs,
ie. if i change the date range to all of 2018, it outputs a value that is the sum of 2018 and 2019 to date..
Do you know of any other formulas that work for calculating sum of same period last year to the current date?
I want to be able to create some extra graphs from this and a better formula would be helpful
YTDPreviousYearRevenue =
CALCULATE (
SUM ( Revenue[Revenue] );
SAMEPERIODLASTYEAR ( DATESYTD ( 'Date Table'[Date] ) )
)
YTDPreviousYearRevenue_2 =
CALCULATE (
SUM ( Revenue[Revenue] );
DATESYTD ( SAMEPERIODLASTYEAR ( 'Date Table'[Date] ) )
)- marcorusso7 years ago
Most Valuable Professional
If you select one month in the Date table, you get the entire month. In the comparison with the previous period you might want to reduce this so you should follow the advices described in this article:
https://www.sqlbi.com/articles/hiding-future-dates-for-calculations-in-dax/