Forum Discussion

Prabha123's avatar
Prabha123
Frequent Visitor
1 year ago
Solved

how to get working experiences based on given data

Hi experts, I am working on a project i have an doubt ,if i have an joining date and resigned date  how to calculate the working experiences of they employees of given data.   Joining date ...
  • rohit1991's avatar
    1 year ago

    Hi Prabha123 ,

    To calculate the working experience (tenure) of employees based on their joining date and resigned date, you can use DAX in Power BI or an Excel formula to determine the duration in years and months. The DATEDIFF function can be used to compute the difference between the Joining Date and Resigned Date, returning the tenure in different time units. Since DATEDIFF only calculates a single unit (years, months, or days), we need to extract the years separately and then compute the remaining months.

    This ensures that the final output correctly reflects the employee's experience in a readable format like "X Years, Y Months". Below is the DAX formula to achieve this in Power BI.

    WorkingExperience = 
    VAR Years = DATEDIFF(EmployeeTable[Joining date], EmployeeTable[Resigned date], YEAR)
    VAR Months = DATEDIFF(EmployeeTable[Joining date], EmployeeTable[Resigned date], MONTH) - (Years * 12)
    RETURN 
        Years & " Years, " & Months & " Months"
    

    his formula ensures that each employee’s tenure is accurately represented while handling variations in months and years effectively.