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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Niels_T
Post Patron
Post Patron

Power Query M Language - Adding 5 years to end of the current year

Hello,

 

I would like to add 5 more years to this M Language function.

= Date.EndOfYear(DateTime.Date(DateTime.FixedLocalNow()))

 

This one returns only the end of the current year.

 

How can I do this?

 

 

1 ACCEPTED SOLUTION

Hello,

 

Thank you for trying to help me.

 

After playing around for a long time I finaly found it.

 

I basically did the following:

= Date.AddYears(Date.EndOfYear(DateTime.Date(DateTime.FixedLocalNow())), 5)

 

This extended the end date by 5 years.

View solution in original post

8 REPLIES 8
Thejeswar
Super User
Super User

Hi @Niels_T ,

You can use the AddYears function.. See below the M Query for the same

#"Added Custom" = Table.AddColumn(#"previous_step", "5_Years_later", each Date.AddYears([Finishtime], 5))

 

PFB sample screenshot

Thejeswar_0-1645183884850.png

 

I'm sorry. I wasn't very clear.

 

I just want to have the original dates but the column needs to be longer by adding 5 more extra years instead of stopping at the current year.

Hi,

Can you share a sample of how you want your output to look like

I would like to have the data as followed:

 

DateDate (5 years extended)
01/01/202101/01/2021
02/01/202102/01/2021
03/01/202103/01/2021
......
 01/01/2025
 01/01/2025

 

Niels_T_0-1645187426879.png

 

 

As you can see dates need to be exactly the same. Just the column needs to be extended by 5 years more.

Hi @Niels_T ,

 

Please try the following formula:

 

let
    Source = Duration.TotalDays( Date.AddYears( Date.EndOfYear( DateTime.Date( DateTime.FixedLocalNow() ) ), 5 ) - DateTime.Date( DateTime.FixedLocalNow() ) ),
    #"List Dates" = List.Dates( #date(2021,1,1), Source, #duration(1,0,0,0) ),
    #"Converted to Table" = Table.FromList(#"List Dates", Splitter.SplitByNothing(), null, null, ExtraValues.Error)
in
    #"Converted to Table"

vkkfmsft_0-1645521607080.png

 

If the problem is still not resolved, please provide detailed error information or the expected result you expect. Let me know immediately, looking forward to your reply.
Best Regards,
Winniz
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

Hello,

 

Thank you for trying to help me.

 

After playing around for a long time I finaly found it.

 

I basically did the following:

= Date.AddYears(Date.EndOfYear(DateTime.Date(DateTime.FixedLocalNow())), 5)

 

This extended the end date by 5 years.

Thak you for great expression - my dax formula wasn't working!

Hi Niels.  This worked perfectly for me, I really appreciate it!!!  Thank you!

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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.

Top Solution Authors
Top Kudoed Authors