March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early bird discount ends December 31.
Register NowBe 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
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:
Employee | Date Commenced | All 5-Year Intervals Commenced | Last 5-Year Interval Commenced | Next 5 Year Interval Commences |
12345 | 17/09/1992 | 17/9/97,17/9/02, 17/9/07, 17/9/12, 17/9/17, 17/9/22 | 17/09/2022 | 17/09/2027 |
23456 | 1/05/2014 | 1/5/19, 1/5/24 | 1/05/2024 | 1/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.
Solved! Go to Solution.
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.
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.
Thank you so much. That worked brilliantly and is scaleable. This community is amazing.
You are welcome.
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.
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?
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.
Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.
User | Count |
---|---|
123 | |
85 | |
85 | |
70 | |
51 |
User | Count |
---|---|
205 | |
153 | |
97 | |
79 | |
69 |