Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
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?
Solved! Go to 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.
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
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:
Date | Date (5 years extended) |
01/01/2021 | 01/01/2021 |
02/01/2021 | 02/01/2021 |
03/01/2021 | 03/01/2021 |
... | ... |
01/01/2025 | |
01/01/2025 |
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"
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.
Hi Niels. This worked perfectly for me, I really appreciate it!!! Thank you!
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
114 | |
100 | |
81 | |
70 | |
62 |
User | Count |
---|---|
148 | |
116 | |
104 | |
90 | |
65 |