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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
N5
Regular 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 Years and 10 Months. DAX formula gives 04 Years and 10 Months. Can someone help me correcting this formula?

Tenure =

VAR EndingDate =
 TODAY()
 
VAR Yr = DATEDIFF('Active Headcount'[Continuous Service Sysco LABS (Internship/Contract/Permanent)], EndingDate, YEAR)
VAR Mo = MOD(DATEDIFF('Active Headcount'[Continuous Service Sysco LABS (Internship/Contract/Permanent)], EndingDate, MONTH),12)

VAR Tenure =
 IF(
 Yr > 0,
 COMBINEVALUES(" ", Yr,"Years", Mo,"Months"),
 COMBINEVALUES(" ", Mo,"Months")
 )
 
RETURN Tenure
1 ACCEPTED SOLUTION
FreemanZ
Super User
Super 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"))

FreemanZ_0-1674455209162.png

 

View solution in original post

3 REPLIES 3
FreemanZ
Super User
Super 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"))

FreemanZ_0-1674455209162.png

 

N5
Regular Visitor

This worked. Thank you soo much!

pratyashasamal
Memorable Member
Memorable Member

Hi @N5 ,

Tenure Months =
var yr = datediff([start_Date],YEAR(TODAY()), year) var mn =datediff([start_Date],MONTH(TODAY()), month) - (datediff([start_Date],YEAR(TODAY()), year) *12)) Return yr + " Years, " + mn + " Months"

Please try this as well
Thanks ,

Pratyasha Samal
Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C

 





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

Proud to be a Super User!





Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.