Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Andrew-Barlow
Regular Visitor

Shifting current calendar year dates back one year issues

Hello Power BI community, 

My team and I encountered some strange results using the dateadd and sameperiodlastyear functions to shift the current calendar year dates back one year. We have a typical date table that includes dates from January 2019 up until the current calendar date. To grab the current period Dates I used the following: CurrentDates = DATESYTD('Date'[Date]), which correctly produces the dates in the current calendar year (1/1/2021 - 7/23/2021). What's interesting is that when I try to shift those dates back one year using: CurrentDatesLY = DATEADD(CurrentDates, -1, YEAR), it includes through 7/31/2021: 

AndrewBarlow_0-1627073770240.png

 

When I use DATEADD(CurrentDates, -365, DAY) it returns the correct range: 

AndrewBarlow_1-1627073884714.png

 

Does anyone have any ideas why this happens? I also used SAMEPERIODLASTYEAR(CurrentDates) and it produced the same issue including to 7/31/2021. If anyone knows what's happening that would be much appreciated, I am currently on version 2.95.804.0.


3 REPLIES 3
vanessafvg
Super User
Super User

I think Marco Russo potentially explains it better than I.  I think this might be the issue around the function you are using.

 

https://www.youtube.com/watch?v=JS-K2faCiCc





If I took the time to answer your question and I came up with a solution, please mark my post as a solution and /or give kudos freely for the effort 🙂 Thank you!

Proud to be a Super User!




The narrator in the referred clip is Alberto Ferrari😀

As pointed out at 3:10 of the clip, the intervention of the invisible ALL() on date column is the crux of unexpected behaviour of TOTALYTD/DATESYTD. Good to see it unveiled!

Cheers!


Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension!

DAX is simple, but NOT EASY!

haha @CNENFRNL  freudian error....you would think i would know that seeing as i have watched more videos from them over the years than i have tv!  however they pretty synonomous with each other in this world 😉





If I took the time to answer your question and I came up with a solution, please mark my post as a solution and /or give kudos freely for the effort 🙂 Thank you!

Proud to be a Super User!




Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.