Anniversary Date =
var IsCurrentYearLeapYear = IF(MOD(YEAR(TODAY()), 400) = 0, "Yes", IF(MOD(YEAR(TODAY()), 4) = 0 && MOD(YEAR(TODAY()), 100) <> 0, "Yes", "No"))
var IsSeniorityDateLeapDay = IF(MONTH('Employee Title'[Seniority Date]) = 2 && DAY('Employee Title'[Seniority Date]) = 29, "Yes", "No")
return (IF(IsCurrentYearLeapYear = "No" && IsSeniorityDateLeapDay = "Yes",
DATE(YEAR(TODAY()), 3, 1),
DATE(YEAR(TODAY()), MONTH('Employee Title'[Seniority Date]), DAY('Employee Title'[Seniority Date]))))
But this doesn't, and it makes it very hard to verify expected results withing the computed column.
Anniversary Date =
var IsCurrentYearLeapYear = IF(MOD(2020, 400) = 0, "Yes", IF(MOD(2020, 4) = 0 && MOD(2020, 100) <> 0, "Yes", "No"))
var IsSeniorityDateLeapDay = IF(MONTH('Employee Title'[Seniority Date]) = 2 && DAY('Employee Title'[Seniority Date]) = 29, "Yes", "No")
return (IF(IsCurrentYearLeapYear = "No" && IsSeniorityDateLeapDay = "Yes",
DATE(YEAR(TODAY()), 3, 1),
DATE(YEAR(TODAY()), MONTH('Employee Title'[Seniority Date]), DAY('Employee Title'[Seniority Date]))))
I get:
Couldn't load the data for this visual
Cannot construct data type date, some of the arguments have values which are not valid.. The exception was raised by the IDataReader interface.
But, If I create a column using the expression I can swap out "YEAR(TODAY())" and "2020" it works just fine
IsCurrentYearLeapYear = IF(MOD(2020, 400) = 0, "Yes", IF(MOD(2020, 4) = 0 && MOD(2020, 100) <> 0, "Yes", "No"))
Of course this would all be moot if there was a built in funtion to determine a Leap Year for a given date