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
Anonymous
Not applicable

How do I add add a new date column exactly two years from another date column?

Hey team,

 

I have a question on how to create a new date column with DAX.

 

I have a column with a certain start date and a second column that may or may not have an end date. I now wish to create a new end date column that has an end date two years from the start date, if the end date column is blank. If the end date column is not blank, then the end date remains the same. So the logic is essentially this:

 

New End Date = 

IF(ISBLANK('Table'[End Date]), 
+2 years from Start Date Column,
'Table'[End Date])

 

I have also visualised it:

 

Start DateEnd DateNew End Date
17/09/2020<blank>16/09/2022
14/10/202013/02/202313/02/2023

 

So as you can see, I'm a little lost when it comes to writing the +2 years from Start Date Column

2 ACCEPTED SOLUTIONS
Jihwan_Kim
Super User
Super User

Hi, @Anonymous 

 

Please try to write the below for creating a new column.

 

New End Date Column =
IF (
NOT ISBLANK ( 'Table'[End Date] ),
'Table'[End Date],
DATE ( YEAR ( 'Table'[Start Date] ) + 2, MONTH ( 'Table'[Start Date] ), DAY ( 'Table'[Start Date] ) )
)

 

Hi, My name is Jihwan Kim.

If this post helps, then please consider accept it as the solution to help other members find it faster, and give a big thumbs up.

Linkedin: https://www.linkedin.com/in/jihwankim1975/

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Go to My LinkedIn Page


View solution in original post

vanessafvg
Super User
Super User

newenddate =
IF (
    ISBLANK ( 'Table'[End Date] ),
    DATEADD ( 'Table'[Start Date]2YEAR ),
    'Table'[End Date]
)





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!




View solution in original post

3 REPLIES 3
Anonymous
Not applicable

Thanks so much both, your solutions have worked very well!

vanessafvg
Super User
Super User

newenddate =
IF (
    ISBLANK ( 'Table'[End Date] ),
    DATEADD ( 'Table'[Start Date]2YEAR ),
    'Table'[End Date]
)





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!




Jihwan_Kim
Super User
Super User

Hi, @Anonymous 

 

Please try to write the below for creating a new column.

 

New End Date Column =
IF (
NOT ISBLANK ( 'Table'[End Date] ),
'Table'[End Date],
DATE ( YEAR ( 'Table'[Start Date] ) + 2, MONTH ( 'Table'[Start Date] ), DAY ( 'Table'[Start Date] ) )
)

 

Hi, My name is Jihwan Kim.

If this post helps, then please consider accept it as the solution to help other members find it faster, and give a big thumbs up.

Linkedin: https://www.linkedin.com/in/jihwankim1975/

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Go to My LinkedIn Page


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.