Hi. Thank you for your question and reaching out. I’d be more than happy to help you with your query.
You can calculate the duration of years in Power Query by subtracting the start date from the end date and then dividing the result by the number of days in a year. Here's an example in Power Query M language:
let
startDate = #date(2019,1,1),
endDate = #date(2023,12,31),
durationInDays = Duration.Days(endDate - startDate),
durationInYears = durationInDays / 365
in
durationInYears
This will give you the duration in decimal years. If you want the duration in whole years, you can round the result down using the RoundDown function. For example:
let
startDate = #date(2019,1,1),
endDate = #date(2023,12,31),
durationInDays = Duration.Days(endDate - startDate),
durationInYears = durationInDays / 365,
durationInWholeYears = RoundDown(durationInYears)
in
durationInWholeYears
This will return the number of full years between the start and end dates.
If the reply was helpful, please don’t forget to upvote or accept as answer, thank you.