To calculate how many months an employee has been in their job as of today using DAX (in Power BI or Analysis Services), you'll typically need a table that contains at least the following columns:
HireDate – the date when the employee started the job
- Optionally,
TerminationDate – if applicable (for employees who have left)
Here’s a basic DAX measure that calculates the number of months worked so far, as of today:
✅ If you're calculating for active employees only (no termination date):
MonthsWorked =
DATEDIFF(
'Employees'[HireDate],
TODAY(),
MONTH
)
This formula calculates the difference in months between the HireDate and today.
✅ If some employees may have a TerminationDate (and you want to use that if it exists):
MonthsWorked =
VAR EmploymentEndDate =
IF(
ISBLANK('Employees'[TerminationDate]),
TODAY(),
'Employees'[TerminationDate]
)
RETURN
DATEDIFF(
'Employees'[HireDate],
EmploymentEndDate,
MONTH
)
This version:
- Uses
TODAY() if the employee is still employed.
- Uses
TerminationDate if available.
- Calculates the total number of months between hire date and end date.
📌 Notes:
- This returns the number of completed months. For example, from Jan 15 to Feb 14 → 0 months; from Jan 15 to Feb 15 → 1 month.
- If you want to include partial months, you can switch from
MONTH to DAY and divide by 30 (or average days per month).
Example with partial months:
MonthsWorkedWithPartial =
VAR EmploymentEndDate =
IF(
ISBLANK('Employees'[TerminationDate]),
TODAY(),
'Employees'[TerminationDate]
)
RETURN
DATEDIFF(
'Employees'[HireDate],
EmploymentEndDate,
DAY
) / 30
Let me know if you want this as a calculated column or a measure, or if you need it filtered by context (like specific departments or roles).