Function to determine the date for Easter Sunday (Power Query)
2023-06-23 Power Query 0 542
The function below returns the date for Easter Sunday for a given year.
Based on the Easter Sunday date you can calculate the date for other religious holidays.
//fxEasterSunday
//returns the date for Easter Sunday
(InputYear as number) as date =>
let
lngGolden = Number.Mod(InputYear, 19) + 1,
lngCentury = Number.IntegerDivide(InputYear, 100) + 1,
lngLeapDayCorr = 3 * Number.IntegerDivide(lngCentury, 4) - 12,
lngMoonSync = Number.IntegerDivide(8 * lngCentury + 5, 25) - 5,
lngSunday = Number.IntegerDivide(5 * InputYear, 4) - lngLeapDayCorr - 10,
lngEpact1 = Number.Mod(11 * lngGolden + 20 + lngMoonSync - lngLeapDayCorr, 30),
lngEpact2 = if lngEpact1 < 0 then lngEpact1 + 30 else lngEpact1,
lngEpact = if ((lngEpact2 = 25 and lngGolden > 11) or lngEpact2 = 24) then lngEpact2 + 1 else lngEpact2,
lngN1 = 44 - lngEpact,
lngN2 = if lngN1 < 21 then lngN1 + 30 else lngN1,
lngN = lngN2 + 7 - Number.Mod(lngSunday + lngN2, 7),
EasterSunday = if lngN <= 31 then #date(InputYear, 3, lngN) else #date(InputYear, 4, lngN - 31)
in
EasterSunday
See also how to calculate the date for Easter Sunday with an Excel formula.