Forum Discussion
CarlsBerg999
Helper V
5 years agoAdd months to date
Hi, Im trying to add dates in a calculated column to a date. For example, I have date 1.5.2021 in Column A and 24 months in column B. I want the result to be 1.5.2023 in column C. However, for so...
- 5 years ago
This can be quite tricky as the dateadd function requires a column reference and that column needs to have the date that would be the result of your addition. The simplest way to do this is to use the EDATE function so some thing like
NewDate = EDATE([Column A],[Column B])
# EDATE only works for months but that works fine in your case.
Jon_vB
Advocate II
3 years agoFor me, I was trying to add 1 to the month inside my Date table definition - so - the fact that DateADD requires a column was annoying, and I couldn't reference the table I was trying to build. My solution was to use the EOMONTH function (EOMONTH - DAX Guide).
(note - this reply was edited - my former answer didn't take into account December to January transition)
"YY-MMM Or Current"
,IF( TODAY() >= DATE( YEAR([Date]), MONTH([Date]), 1) && TODAY() <= EOMONTH([Date],0)
, "Current Month"
, FORMAT(DATE(YEAR([Date]),MONTH([Date]) ,1),"YYYY-MMM")
)