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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

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
Sept PBI Carousel

Power BI Monthly Update - September 2024

Check out the September 2024 Power BI update to learn about new features.

September Hackathon Carousel

Microsoft Fabric & AI Learning Hackathon

Learn from experts, get hands-on experience, and win awesome prizes.

Sept NL Carousel

Fabric Community Update - September 2024

Find out what's new and trending in the Fabric Community.