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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Pigbag1962
Frequent Visitor

Measure to Get Previous Years date as a Year

Hi

 

I am trying to get the previous year in YYYY format based on the last date in rolling stock table.

 

I have managed to get there but it has taken me 3 measures. Is there a way to amalgamte these into one measure or is there a better alternative?

 

Measure 1 gets the last date in table

LastDate = LASTDATE('Rolling Livestock Data'[Create dte])
 
Measure 2 gets the date 1 year earlier based on measure 1
LastYearDate = DATEADD(LASTDATE('Rolling Livestock Data'[Create dte]),-1,YEAR)
 
Measure 3 uses Year function to contract measure 2 output to YYYY
LY Year = year([LastYearDate])
 
Cheers
 
Damon
1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@Pigbag1962 , change the second one like

 

LastYearDate =

var _1 = LASTDATE('Rolling Livestock Data'[Create dte])

return

date(year(_1) -1, month(_1), day(_1))

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

2 REPLIES 2
Pigbag1962
Frequent Visitor

Thank you for that, gives me more insight as to how to use DAX.

 

amitchandak
Super User
Super User

@Pigbag1962 , change the second one like

 

LastYearDate =

var _1 = LASTDATE('Rolling Livestock Data'[Create dte])

return

date(year(_1) -1, month(_1), day(_1))

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.