Forum Discussion
Calculate Retention & Turnover %
Hey there,
Can someone help me calculate the following in Power BI :
Retention - % calculated with = 1 - Number of employees that left the company and that were hired in the previous 12 months / Number of hires in the previous 12 months
Turnover - % calculated with = Number of employees that left in the previous 12 months / (Total Employees in the previous 12 months + Number of employees that left in the previous 12 months)
The column 'date of resignment' tells me if an employee left.
- Anonymous5 years ago
Hi Anonymous
Due to I don't know your data model, I build a sample to have a test.
My Sample:
Build a Date table by dax code.
Date = VAR _T = ADDCOLUMNS ( CALENDARAUTO (), "Year", YEAR ( [Date] ), "Month", MONTH ( [Date] ), "YearMonth", YEAR ( [Date] ) * 100 + MONTH ( [Date] ), "MonthName", FORMAT ( [Date], "MMMM" ) ) VAR _T2 = ADDCOLUMNS ( _T, "Rank", RANKX ( _T, [YearMonth],, ASC, DENSE ) ) RETURN _T2Measures:
Retention - % calculated with = VAR _Previous12START = EOMONTH ( MAX ( 'Date'[Date] ), -13 ) + 1 VAR _Previous12END = EOMONTH ( MAX ( 'Date'[Date] ), -1 ) VAR _LEFT = CALCULATE ( COUNT ( 'Sample'[Employee] ), FILTER ( ALL ( 'Sample' ), 'Sample'[Check in Date] >= _Previous12START && 'Sample'[Check in Date] <= _Previous12END && 'Sample'[Date of Resignment] >= _Previous12START && 'Sample'[Date of Resignment] <= _Previous12END ) ) + 0 VAR _Total = CALCULATE ( COUNT ( 'Sample'[Employee] ), FILTER ( ALL ( 'Sample' ), 'Sample'[Check in Date] <= _Previous12END && OR ( 'Sample'[Date of Resignment] >= _Previous12START, 'Sample'[Date of Resignment] = BLANK () ) ) ) RETURN 1 - DIVIDE ( _LEFT, _Total )Turnover - % calculated with = //Number of employees that left in the previous 12 months / (Total Employees in the previous 12 months + Number of employees that left in the previous 12 months) VAR _Previous12START = EOMONTH ( MAX ( 'Date'[Date] ), -13 ) + 1 VAR _Previous12END = EOMONTH ( MAX ( 'Date'[Date] ), -1 ) VAR _LEFT = CALCULATE ( COUNT ( 'Sample'[Employee] ), FILTER ( ALL ( 'Sample' ), 'Sample'[Date of Resignment] >= _Previous12START && 'Sample'[Date of Resignment] <= _Previous12END ) ) VAR _TOTAL = CALCULATE ( COUNT ( 'Sample'[Employee] ), FILTER ( ALL ( 'Sample' ), 'Sample'[Check in Date] <= _Previous12END && OR ( 'Sample'[Date of Resignment] >= _Previous12START, 'Sample'[Date of Resignment] = BLANK () ) ) ) RETURN DIVIDE ( _LEFT, _TOTAL )If this reply still couldn't help you solve your problem, please share a sample with me by your Onedrive for Business. And show me more details about your calculate logic. You can show me the result you want by screenshot as well.
Best Regards,
Rico ZhouIf this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
3 Replies
- AnonymousNot applicable
Hi Anonymous
Due to I don't know your data model, I build a sample to have a test.
My Sample:
Build a Date table by dax code.
Date = VAR _T = ADDCOLUMNS ( CALENDARAUTO (), "Year", YEAR ( [Date] ), "Month", MONTH ( [Date] ), "YearMonth", YEAR ( [Date] ) * 100 + MONTH ( [Date] ), "MonthName", FORMAT ( [Date], "MMMM" ) ) VAR _T2 = ADDCOLUMNS ( _T, "Rank", RANKX ( _T, [YearMonth],, ASC, DENSE ) ) RETURN _T2Measures:
Retention - % calculated with = VAR _Previous12START = EOMONTH ( MAX ( 'Date'[Date] ), -13 ) + 1 VAR _Previous12END = EOMONTH ( MAX ( 'Date'[Date] ), -1 ) VAR _LEFT = CALCULATE ( COUNT ( 'Sample'[Employee] ), FILTER ( ALL ( 'Sample' ), 'Sample'[Check in Date] >= _Previous12START && 'Sample'[Check in Date] <= _Previous12END && 'Sample'[Date of Resignment] >= _Previous12START && 'Sample'[Date of Resignment] <= _Previous12END ) ) + 0 VAR _Total = CALCULATE ( COUNT ( 'Sample'[Employee] ), FILTER ( ALL ( 'Sample' ), 'Sample'[Check in Date] <= _Previous12END && OR ( 'Sample'[Date of Resignment] >= _Previous12START, 'Sample'[Date of Resignment] = BLANK () ) ) ) RETURN 1 - DIVIDE ( _LEFT, _Total )Turnover - % calculated with = //Number of employees that left in the previous 12 months / (Total Employees in the previous 12 months + Number of employees that left in the previous 12 months) VAR _Previous12START = EOMONTH ( MAX ( 'Date'[Date] ), -13 ) + 1 VAR _Previous12END = EOMONTH ( MAX ( 'Date'[Date] ), -1 ) VAR _LEFT = CALCULATE ( COUNT ( 'Sample'[Employee] ), FILTER ( ALL ( 'Sample' ), 'Sample'[Date of Resignment] >= _Previous12START && 'Sample'[Date of Resignment] <= _Previous12END ) ) VAR _TOTAL = CALCULATE ( COUNT ( 'Sample'[Employee] ), FILTER ( ALL ( 'Sample' ), 'Sample'[Check in Date] <= _Previous12END && OR ( 'Sample'[Date of Resignment] >= _Previous12START, 'Sample'[Date of Resignment] = BLANK () ) ) ) RETURN DIVIDE ( _LEFT, _TOTAL )If this reply still couldn't help you solve your problem, please share a sample with me by your Onedrive for Business. And show me more details about your calculate logic. You can show me the result you want by screenshot as well.
Best Regards,
Rico ZhouIf this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
- EgemenyFrequent Visitor
Hi Anonymous ,
Thank you for this solution! It works like magic.
I would like to drill down further to see retention % based on job titles and business units. How can i achieve this? Do I need to add an additional 'filter' function in the above dax?
If so what can that look like?
Thanks a lot for your support!
- amitchandak
Super User
Anonymous , need to know data model and table columns.
But you can create hire and terminated employee like give in blog. and then can try this for the last 12 months
example
Rolling 12 = CALCULATE([hire],DATESINPERIOD('Date'[Date ],MAX('Date'[Date ]),-12,MONTH))
Rolling 12 = CALCULATE([terminated],DATESINPERIOD('Date'[Date ],MAX('Date'[Date ]),-12,MONTH))