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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
PowerBeeTree
Frequent Visitor

calculated column of same date last year using SAMEPERIODLASTYEAR or PREVIOUSYEAR or DATEADD

I have the following date table and i want to create a calculated column using either the SAMEPERIODLASTYEAR or PREVIOUSYEAR or DATEDIFF and not the easy escape of recreating it via DATE() as i want leap years to be taken care of and also to understand better how DAX works.

 

Here is an example date table TBL:

 

date

03/01/2024
03/02/2024
03/03/2024
03/04/2024
03/05/2024
03/06/2024
03/07/2024
03/08/2024
03/09/2024
03/10/2024
03/11/2024
03/12/2024
03/13/2024
03/14/2024

 

for ease let's call the calculated column "LAST_YEAR"

 

Tried all of the following with the respective issued i got stuck at:

  • SAMEPERIODLASTYEAR: the "LAST_YEAR" column is empty when i check the table in the table view
  • PREVIOUSYEAR: returns a table and not sure how to parse the value (which i can see in DAX studio)
  • DATEADD: i use the following but again the column is empty as it seems that the returned value is a table and not a single value.

 

 

DATEADD(TBL[date], -1, YEAR) 

 

 

 

1 ACCEPTED SOLUTION
Greg_Deckler
Super User
Super User

@PowerBeeTree Take a look at the video below. The PBIX file is available from the associated GitHub repository. You may find this helpful - https://community.powerbi.com/t5/Community-Blog/To-bleep-With-Time-Intelligence/ba-p/1260000

 

This should allow you to understand how those functions are *supposed* to work.

Also, see if my Time Intelligence the Hard Way provides a different way of accomplishing what you are going for.
https://community.powerbi.com/t5/Quick-Measures-Gallery/Time-Intelligence-quot-The-Hard-Way-quot-TIT...

 

 


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

2 REPLIES 2
PowerBeeTree
Frequent Visitor

helpful resources to understand how these functions work and understand if these tasks can be completed. Looks like the name of the functions is confusing and won't allow by design to achieve the task at request.

Greg_Deckler
Super User
Super User

@PowerBeeTree Take a look at the video below. The PBIX file is available from the associated GitHub repository. You may find this helpful - https://community.powerbi.com/t5/Community-Blog/To-bleep-With-Time-Intelligence/ba-p/1260000

 

This should allow you to understand how those functions are *supposed* to work.

Also, see if my Time Intelligence the Hard Way provides a different way of accomplishing what you are going for.
https://community.powerbi.com/t5/Quick-Measures-Gallery/Time-Intelligence-quot-The-Hard-Way-quot-TIT...

 

 


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

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.