Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Vote for your favorite vizzies from the Power BI Dataviz World Championship submissions. Vote now!

Reply
Victormar
Helper V
Helper V

Year calculation for leap years

Hello, community

 

I have a situation where I have contracted dates for vehicles, and I need to calculate the renovation date, which is after 6 months and after one year. The thing is that I have some vehicles with starting contracts on the 1st of March, therefore when I do a formula where I add a year to it, it can happen that the result is the 2nd (If I am not wrong, Power BI just adds 365 days to it, and I am guessing for shortened February years that is a potential problem).

 

This is my formula:

c_AnniversaryDate =
VAR six_months =
    DATE ( YEAR ( [Current year start date] ), MONTH ( DIM_Chassis[CONTRACT_START_DATE] ) + 6, DAY ( DIM_Chassis[CONTRACT_START_DATE] ) )
VAR twelve_months =
    DATE ( YEAR ( [Current year start date] ) + 1, MONTH ( DIM_Chassis[CONTRACT_START_DATE] ), DAY ( DIM_Chassis[CONTRACT_START_DATE] ) )
RETURN
    IF (
        [Current year start date] < TODAY ()
            && TODAY () > six_months,
        twelve_months,
        six_months
    )

 

Does anybody know how to solve that scenario?

 

Thanks in advance for your time 🙂

1 ACCEPTED SOLUTION
danextian
Super User
Super User

Hi @Victormar 

 

Instead of adding a 1 to the year or 6 to the month, why not just use EDATE?  EDATE ( DATE (2024, 3, 1), 18 ) is DATE (2025, 9, 1) which is 18 months after the original date. Or if you want the date 18 months prior, just use -18.
March 1, 2024 becomes





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

Did I answer your question? Mark my post as a solution!


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

View solution in original post

2 REPLIES 2
Victormar
Helper V
Helper V

thanks! that worked really good!

danextian
Super User
Super User

Hi @Victormar 

 

Instead of adding a 1 to the year or 6 to the month, why not just use EDATE?  EDATE ( DATE (2024, 3, 1), 18 ) is DATE (2025, 9, 1) which is 18 months after the original date. Or if you want the date 18 months prior, just use -18.
March 1, 2024 becomes





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

Did I answer your question? Mark my post as a solution!


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

Vote for your favorite vizzies from the Power BI World Championship submissions!

Sticker Challenge 2026 Carousel

Join our Community Sticker Challenge 2026

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

January Power BI Update Carousel

Power BI Monthly Update - January 2026

Check out the January 2026 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.