cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Super User
Super User

SAMEPERIODLASTYEAR(DATESYTD( )) different from DATESYTD(SAMEPERIODLASTYEAR( ))??

Hi all,

This came up as I was trying to answer this post by @hbolo (no need to read it to answer this question). Here is the pbix

We have a Date table with dates between 01/01/2018 and today (Jan 3rd, 2019).

We place Date[Date] (down to the day level) in the rows of a matrix visual and these two measures in values:

 

YTDPreviousYearRevenue =
CALCULATE (
    SUM ( Revenue[Revenue] );
    SAMEPERIODLASTYEAR ( DATESYTD ( 'Date Table'[Date] ) )
)
YTDPreviousYearRevenue_2 =
CALCULATE (
    SUM ( Revenue[Revenue] );
    DATESYTD ( SAMEPERIODLASTYEAR ( 'Date Table'[Date] ) )
)

where we are simply calculating the YTD revenue for the previous year.

 

For January 3rd, 2019 (the last day on the Date table),
[YTDPreviousYearRevenue_ 2] yields the correct result (i.e. the revenue for 1-3 Jan 2018).

However, [YTDPreviousYearRevenue] yields an incorrect result: the revenue for 1-31 Jan 2018. [YTDPreviousYearRevenue] is thus considering the full month of January 2018 while the YTD of 2019 is only 1-3 Jan, the first 3 days I would expect both measures to yield the exact same result.

Note that [YTDPreviousYearRevenue] yields the correct result for the 1st and 2nd Jan 2019. The only issue seems to be on the 3rd Jan 2019, the last day on the Date table.

 

Does anybody know what is going on?

Many thanks for your help
 
Note: I suspect it has to do with the Date table finishing on Jan 3rd, 2019 but do not know why. If the Date table is extended to include dates up to the end of 2019 this problem disappears.

1 ACCEPTED SOLUTION

Accepted Solutions
marcorusso Member
Member

Re: SAMEPERIODLASTYEAR(DATESYTD( )) different from DATESYTD(SAMEPERIODLASTYEAR( ))??

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.

 

View solution in original post

20 REPLIES 20
Community Support Team
Community Support Team

Re: SAMEPERIODLASTYEAR(DATESYTD( )) different from DATESYTD(SAMEPERIODLASTYEAR( ))??

hi, @AlB I asked the Power BI TA team about this question. and if there is any feedback, I'll update it right here. Best Regards, Lin
Community Support Team _ Lin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Super User
Super User

Re: SAMEPERIODLASTYEAR(DATESYTD( )) different from DATESYTD(SAMEPERIODLASTYEAR( ))??

Hi @v-lili6-msft

Thanks very much. I look forward to hearing from them. 

Super User
Super User

Re: SAMEPERIODLASTYEAR(DATESYTD( )) different from DATESYTD(SAMEPERIODLASTYEAR( ))??

Perhaps very knowledgeable people like @Zubair_Muhammad, @Greg_Deckler, @MFelix would care to chip in?

Many thanks

Super User
Super User

Re: SAMEPERIODLASTYEAR(DATESYTD( )) different from DATESYTD(SAMEPERIODLASTYEAR( ))??

@AlB

 

Very interesting

 

I remember you found a bug before as well  Smiley Wink

I am not sure why this is happening

but if we use following we get correct results even with the last date.

YTDPreviousYearRevenue = 
CALCULATE (
    SUM ( Revenue[Revenue] ),
    SAMEPERIODLASTYEAR ( DATESYTD ( 'Date Table'[Date].[Date]) )
) 

 

Super User
Super User

Re: SAMEPERIODLASTYEAR(DATESYTD( )) different from DATESYTD(SAMEPERIODLASTYEAR( ))??

Thanks very much @Zubair_Muhammad

It gets more and more intriguing. Let's see what the others say.

Super User
Super User

Re: SAMEPERIODLASTYEAR(DATESYTD( )) different from DATESYTD(SAMEPERIODLASTYEAR( ))??

Hi @AIB,

Check the blog post below were it shows different options mayve is a good starting point to get the best option.

http://radacad.com/dateadd-vs-parallelperiod-vs-sameperiodlastyear-dax-time-intelligence-question

Regards,
MFelix


Did I answer your question? Mark my post as a solution!

Proud to be a Datanaut!




Super User
Super User

Re: SAMEPERIODLASTYEAR(DATESYTD( )) different from DATESYTD(SAMEPERIODLASTYEAR( ))??

Hi @AIB,

Forgot to mention not on the computer right now but will try and have a look at your PBIX file later.

Regards,
MFelix


Did I answer your question? Mark my post as a solution!

Proud to be a Datanaut!




Super User
Super User

Re: SAMEPERIODLASTYEAR(DATESYTD( )) different from DATESYTD(SAMEPERIODLASTYEAR( ))??

Thanks @MFelix.

No worries. It's not urgent

Super User
Super User

Re: SAMEPERIODLASTYEAR(DATESYTD( )) different from DATESYTD(SAMEPERIODLASTYEAR( ))??

Hi @v-lili6-msft

Have you heard anything about this?

Thanks

Helpful resources

Announcements
Ask Amir Anything

Exclusive LIVE Community Event No. 2 – Ask Amir Anything

Next in our Triple A series: Ask Amir Netz questions about the latest updates, features and future.

October 2019 Community Highlights

October 2019 Community Highlights

October was a busy month in the community. Read the recap article to learn about some of the events and content.

New Solution Badges

New Solution Badges

Two waves of brand new solution badges are coming! Read the article for more information on our new community badges.

Analytics in Azure virtual event

Analytics in Azure virtual event

Experience a limitless analytics service built to ingest, prep, manage, and serve data for immediate use in Power BI.

Users Online
Currently online: 71 members 949 guests
Please welcome our newest community members: