cancel
Showing results for
Did you mean:
Highlighted
Super User III

## 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?

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
MVP

## 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.

20 REPLIES 20
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 III

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

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

Super User III

## 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 III

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

@AlB

Very interesting

I remember you found a bug before as well

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]) )
) ```

Try my new Power BI game Cross the River
Super User III

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

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

Super User III

## 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.

Regards,
MFelix

Regards

Miguel Felix

Proud to be a Datanaut!

Super User III

## 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

Regards

Miguel Felix

Proud to be a Datanaut!

Super User III

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

Thanks @MFelix.

No worries. It's not urgent

Super User III

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

Thanks

Announcements

#### Meet the 2020 Season 1 Power BI Super Users!

It’s the start of a new Super User season! Learn all about the new Super Users and brand-new tiered recognition system.

#### Super User Challenge: Can You Solve These?

We're celebrating the start of the New Super User season with our first ever Super User 'Can You Solve These?' challenge.

#### January 2020 Community Highlights

Make sure you didn't miss any of the things that happened in the community in January!

Top Solution Authors
Top Kudoed Authors