Forum Discussion
N5
3 years agoRegular Visitor
Tenure Calculation in PowerBI - Incorrect Year calculation
Hi All, I used the below DAX formula for the tenure calculation in PowerBI. But it gives wrong calculation for the Year. For example someone who joined in 25 March 2019. Ideally it should be 3 Ye...
- 3 years ago
hi N5
try like:
Tenure = VAR _months = DATEDIFF('Active Headcount'[Continuous Service Sysco LABS (Internship/Contract/Permanent)], TODAY(), MONTH) VAR _year = TRUNC(DIVIDE(_months, 12)) VAR _month = MOD(_months, 12) RETURN IF(_year=0,BLANK(), IF(_year=1, _year&" Year ", _year&" Years ")) & IF(_month=0, BLANK(), IF(_month=1, _month&" Month", _month&" Months"))
FreemanZ
3 years agoSuper User
hi N5
try like:
Tenure =
VAR _months = DATEDIFF('Active Headcount'[Continuous Service Sysco LABS (Internship/Contract/Permanent)], TODAY(), MONTH)
VAR _year = TRUNC(DIVIDE(_months, 12))
VAR _month = MOD(_months, 12)
RETURN
IF(_year=0,BLANK(), IF(_year=1, _year&" Year ", _year&" Years "))
&
IF(_month=0, BLANK(), IF(_month=1, _month&" Month", _month&" Months"))
- N53 years agoRegular Visitor
This worked. Thank you soo much!