Forum Discussion
Retention Rate
- 4 years ago
Hi Anonymous
Here's an option for a Retention Rate measure.
It gets a list of employees at the start of the period, another list of those at the end, then uses INTERSECT to see employees in both. I've assumed a blank end date means the employee hasn't left.
The IF function is to stop you getting a retention rate until the period is finished.
Retention Rate = VAR _StartOfPeriod = MIN('Date'[Date]) VAR _EndOfPeriod = MAX('Date'[Date]) VAR _Result = IF( TODAY() >= _EndOfPeriod, VAR _EmployeesAtStart = CALCULATETABLE( VALUES(Employees[Employee_ID]), Employees[StartDate] <= _StartOfPeriod, Employees[EndDate] >= _StartOfPeriod || ISBLANK(Employees[EndDate]) ) VAR _EmployeesAtEnd = CALCULATETABLE( VALUES(Employees[Employee_ID]), Employees[StartDate] <= _EndOfPeriod, Employees[EndDate] >= _EndOfPeriod || ISBLANK(Employees[EndDate]) ) VAR _NoOFEmployeesAtStartAndEnd = COUNTROWS( INTERSECT(_EmployeesAtStart, _EmployeesAtEnd) ) RETURN DIVIDE(_NoOFEmployeesAtStartAndEnd, COUNTROWS(_EmployeesAtStart)) ) RETURN _Result
Hi PaulOlding ,
Thanks a lot for the code.
I've done it and I'm not having the expected result. I've tried to figure it out but with no success.
With the code i'm having only one value in a chart X time, for the first period. All the others are empty. Any idea what could be the problem? I'll keep trying something here and if I get anything I update you here.
Hi Is Ano a column that's in your date table? The same one that's in this line of code?
VAR _StartOfPeriod = MIN('Date'[Date])
Also, is the date table disconnected from the rest of the model?
Anonymous
- Anonymous4 years agoNot applicable
PaulOlding "Ano" is "Year" in portuguese. It's from my date table and it is all connected.
- PaulOlding4 years agoSolution Sage
Anonymous
OK. let's try disconnecting it from the rest of the model (or importing a new copy of the date table and using that)
- Anonymous4 years agoNot applicable
PaulOlding Wooow... It worked. I think... I have to make a hand calculation to check, but the values make some sense. I didnt knew I could use tables with no relation. Why does that work and not with?