Forum Discussion

OutOfController's avatar
OutOfController
New Member
2 years ago
Solved

Managing leap year comparisons

Hi everybody,

I'm facing problems trying to set up a comparison between current (leap) year and previous (non leap) year values.

I created a measure like the following:

 

 

VAR Leap = calculate([ACT CALC],dateadd(SAMEPERIODLASTYEAR('Date'[FULLDATE]),+2,DAY))    --Leap year +2
VAR Non_Leap = calculate([ACT CALC],dateadd(SAMEPERIODLASTYEAR('Date'[FULLDATE]),+1,DAY))      --Non leap
VAR Leap_Years = {2020, 2024, 2028, 2032, 2036}                                                          --Leap years vector
RETURN
if(or(and(SELECTEDVALUE('Date'[Month])>2,SELECTEDVALUE('Date'[year])in Leap_Years),and(SELECTEDVALUE('Date'[Month])<3,SELECTEDVALUE('Date'[year])-1 in Leap_Years)),Leap,Non_Leap)

 

 

This works properly on single days and months, but create a lot of troubles in the full year total, that is not the sum of monthly values.
Are there any suggestions to go beyond these problems?

Thanks a lot.

3 Replies