Forum Discussion
Fair-UL
4 years agoHelper II
Calculate Time between two dates on different rows
My issue is a bit tricky. I have this mock dataset with employees, levels, training group, and dates of start of level. not all employees are L2 in all training groups. I want to be able to calculate...
v-henryk-mstf
4 years agoCommunity Support
Hi Fair-UL ,
According to your description, I did a test reference as follows:
col_l2 =
CALCULATE (
MIN ( 'Table'[L1 start date] ),
FILTER (
ALL ( 'Table' ),
'Table'[training group] = EARLIER ( 'Table'[training group] )
)
)Col =
var a = MONTH('Table'[L2 start date])-MONTH('Table'[col_l2])
var b = YEAR('Table'[L2 start date])-YEAR('Table'[col_l2])
return
IF('Table'[L2 start date]<>0,IF(a>=0, b*12+a,b*12-a))
If the problem is still not resolved, please provide detailed error information and let me know immediately. Looking forward to your reply.
Best Regards,
Henry
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Fair-UL
4 years agoHelper II
the issue is in column col_l2, I need to calculate the time between L1 and L2 start dates for any employee who has L2 in a training group. So, for employee1, I need to find the time between 2/1/2020 and 10/1/2021 [20 months] . any other L1 start date can be ignored for any training groups for that employee unless he has another L2 start date for another training group