cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
JemmaD
Resolver I
Resolver I

Numerical value representing number of years from current year

Please can someone help me with a calculated column in Dax, I want a numerical value representing the number of years prior to the current year based on a [Date] column. So the current year of 2022 = 0, 2021 = 1, 2020 = 2, 2019 = 3 and so on. I don't mind if it's negative values: 0, -1, -2 -3.

 

Thanks in advance!

1 ACCEPTED SOLUTION
Greg_Deckler
Super User
Super User

@JemmaD Try:

Column =
  VAR __CurrentYear = YEAR(TODAY())
RETURN
  __CurrentYear - YEAR([Date])

@ 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!:
Mastering Power BI 2nd Edition

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

2 REPLIES 2
Greg_Deckler
Super User
Super User

@JemmaD Try:

Column =
  VAR __CurrentYear = YEAR(TODAY())
RETURN
  __CurrentYear - YEAR([Date])

@ 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!:
Mastering Power BI 2nd Edition

DAX is easy, CALCULATE makes DAX hard...

Thanks Greg that was perfect

Helpful resources

Announcements
PBI Sept Update Carousel

Power BI September 2023 Update

Take a look at the September 2023 Power BI update to learn more.

Learn Live

Learn Live: Event Series

Join Microsoft Reactor and learn from developers.

Dashboard in a day with date

Exclusive opportunity for Women!

Join us for a free, hands-on Microsoft workshop led by women trainers for women where you will learn how to build a Dashboard in a Day!

Top Solution Authors