Get certified for free when you join Fabric Data Days 2026 and dive into Fabric, Power BI, SQL, AI, and other essential data skills.
Join nowJuly 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more
Hi,
I have an Employee table which has ID,name,Department,Hire date etc.. , I want to calculate total Service period for Employees in Years , Months , Days by substracting Hire date from Today every time the report is opened , I used two methods
1. I created A measure as follows
2. I created 2 columns , one for today's date and another as follows
Solved! Go to Solution.
Hi @nadir
Please try the following measures. I didn't test them with many instances, so feel free to let me know if they don't work in some conditions.
Today = TODAY()Years = INT(YEARFRAC(SELECTEDVALUE('Table'[HIRE_DATE]),[Today],1))Months = INT(MOD(YEARFRAC(SELECTEDVALUE('Table'[HIRE_DATE]),[Today],1),1)*12)Days =
VAR _HireDate = SELECTEDVALUE ( 'Table'[HIRE_DATE] )
VAR _Today = [Today]
VAR _LastMonthDays = DAY ( EOMONTH ( [Today], -1 ) )
VAR _days =
SWITCH (
TRUE (),
DAY ( _HireDate ) <= DAY ( _Today ), DAY ( _Today ) - DAY ( _HireDate ),
DAY ( _HireDate ) > DAY ( _Today ), DAY ( _Today ) + ( _LastMonthDays - DAY ( _HireDate ) )
)
RETURN
_daysRegards,
Community Support Team _ Jing Zhang
If this post helps, please consider Accept it as the solution to help other members find it.
Hi @nadir
Please try the following measures. I didn't test them with many instances, so feel free to let me know if they don't work in some conditions.
Today = TODAY()Years = INT(YEARFRAC(SELECTEDVALUE('Table'[HIRE_DATE]),[Today],1))Months = INT(MOD(YEARFRAC(SELECTEDVALUE('Table'[HIRE_DATE]),[Today],1),1)*12)Days =
VAR _HireDate = SELECTEDVALUE ( 'Table'[HIRE_DATE] )
VAR _Today = [Today]
VAR _LastMonthDays = DAY ( EOMONTH ( [Today], -1 ) )
VAR _days =
SWITCH (
TRUE (),
DAY ( _HireDate ) <= DAY ( _Today ), DAY ( _Today ) - DAY ( _HireDate ),
DAY ( _HireDate ) > DAY ( _Today ), DAY ( _Today ) + ( _LastMonthDays - DAY ( _HireDate ) )
)
RETURN
_daysRegards,
Community Support Team _ Jing Zhang
If this post helps, please consider Accept it as the solution to help other members find it.
@nadir , In this case, better to try a column like
Service in Years in Column = DATEDIFF('pp EMPLOYEES'[HIRE_DATE_G],'pp EMPLOYEES'[Todays date],Month)/12.0
check if this works better
Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.
Join Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.
| User | Count |
|---|---|
| 27 | |
| 23 | |
| 18 | |
| 18 | |
| 15 |
| User | Count |
|---|---|
| 54 | |
| 44 | |
| 42 | |
| 39 | |
| 36 |