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.
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 Date | End Date | New End Date |
17/09/2020 | <blank> | 16/09/2022 |
14/10/2020 | 13/02/2023 | 13/02/2023 |
So as you can see, I'm a little lost when it comes to writing the +2 years from Start Date Column.
Solved! Go to Solution.
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.
newenddate =
IF (
ISBLANK ( 'Table'[End Date] ),
DATEADD ( 'Table'[Start Date], 2, YEAR ),
'Table'[End Date]
)
Proud to be a Super User!
Thanks so much both, your solutions have worked very well!
newenddate =
IF (
ISBLANK ( 'Table'[End Date] ),
DATEADD ( 'Table'[Start Date], 2, YEAR ),
'Table'[End Date]
)
Proud to be a 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.
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
113 | |
97 | |
85 | |
70 | |
61 |
User | Count |
---|---|
151 | |
121 | |
104 | |
87 | |
67 |