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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
JulieLamberth
New Member

Get the most recent start date following 5 year intervals

Hi there.  This may seem like a strange query, however I have some data with employees' start dates and I need to find out the beginning of the most recent 5-year interval since each person commenced and when the next 5-year interval begins.  These will be different for each person, depending on their date commenced.

 

Below is an example of the type of data I currently have (columns 1 and 2), my own calculations (column 3 - not required as output for my purposes) and what I would like to see in columns 4 and 5)  I also have a column with DateTime.LocalNow() to reference the current date:

EmployeeDate CommencedAll 5-Year Intervals CommencedLast 5-Year Interval CommencedNext 5 Year Interval Commences
1234517/09/199217/9/97,17/9/02, 17/9/07, 17/9/12, 17/9/17, 17/9/2217/09/202217/09/2027
234561/05/20141/5/19, 1/5/241/05/20241/05/2029

 

Is anyone able to point me in the right direction of how to get columns 4 and 5 please?  If so I would be eternally grateful.

1 ACCEPTED SOLUTION
Ashish_Mathur
Super User
Super User

Hi,

Write these calculated column formulas

Last 5 year interval commenced = EDATE(Data[Date Commenced],120*int(DIVIDE(DATEDIFF(Data[Date Commenced],today(),MONTH),120)))
Next 5 year interval commences = EDATE([Last 5 year interval commenced],60)

Hope this helps.

Ashish_Mathur_0-1726626062875.png

 


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

View solution in original post

5 REPLIES 5
Ashish_Mathur
Super User
Super User

Hi,

Write these calculated column formulas

Last 5 year interval commenced = EDATE(Data[Date Commenced],120*int(DIVIDE(DATEDIFF(Data[Date Commenced],today(),MONTH),120)))
Next 5 year interval commences = EDATE([Last 5 year interval commenced],60)

Hope this helps.

Ashish_Mathur_0-1726626062875.png

 


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Thank you so much.  That worked brilliantly and is scaleable.  This community is amazing.

You are welcome.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
rajendraongole1
Super User
Super User

Hi @JulieLamberth - Create a calculate the most recent 5-year interval prior to today, based on the employee's start date

Last 5-Year Interval Commenced =
VAR StartDate = [Date Commenced]
VAR YearsSinceStart = DATEDIFF(StartDate, TODAY(), YEAR)
VAR LastIntervalYears = INT(YearsSinceStart / 5) * 5
RETURN
DATE(YEAR(StartDate) + LastIntervalYears, MONTH(StartDate), DAY(StartDate))

 

create another calculated column will calculate the next 5-year interval that begins after today, based on the employee's start date

Next 5-Year Interval Commences =
VAR StartDate = [Date Commenced]
VAR YearsSinceStart = DATEDIFF(StartDate, TODAY(), YEAR)
VAR NextIntervalYears = (INT(YearsSinceStart / 5) + 1) * 5
RETURN
DATE(YEAR(StartDate) + NextIntervalYears, MONTH(StartDate), DAY(StartDate))

 

Hope this helps.





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

Proud to be a Super User!





Thank you for such a prompt reply.  However I am having problems - probably because I'm doing it wrong.  I used the Custom Column function on the Add Column menu, copied your formula into it but am getting an error on the first line.  Am I trying to put this formula in the wrong place?

 

JulieLamberth_0-1726619148749.png

 

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.