Forum Discussion
Linnil
2 years agoHelper III
Let Statement (Step) with IF Statement
Hi everyone - I'm just learning how to make Let Statements as Steps. I have this problem - I'm calculating Years of Service, at 30 Apr 23. However, if the person has left / if Status is T, then...
- 2 years ago
Hi Linnil
Assuming you have a [Status] and [Term Date] field, like [Hire Date] in in your table, try this:
let startDate = [Hire Date], endDate = if [Status] = "T" then [Term Date] else #date(2023,04,30), durationInDays = Duration.Days(endDate - startDate), durationInYears = durationInDays / 365 in durationInYearsI hope this is helpful
m_dekorte
2 years agoResident Rockstar
Hi Linnil
Assuming you have a [Status] and [Term Date] field, like [Hire Date] in in your table, try this:
let
startDate = [Hire Date],
endDate = if [Status] = "T" then [Term Date] else #date(2023,04,30),
durationInDays = Duration.Days(endDate - startDate),
durationInYears = durationInDays / 365
in
durationInYears
I hope this is helpful
Linnil
2 years agoHelper III
Thank you for this! (sorry for late reply, it was a crazy week).
Have a lovely weekend 🙂