Formula to Calculate Attrition Rate

Attrition Rate Calculator

Attrition rate, often referred to as churn rate, is a key metric for businesses to understand how many customers or employees they are losing over a specific period. A high attrition rate can indicate underlying issues with product, service, or employee satisfaction. Calculating this rate helps businesses identify problems and implement strategies to improve retention.

function calculateAttritionRate() { var employeesAtStart = parseFloat(document.getElementById("employeesAtStart").value); var employeesAtEnd = parseFloat(document.getElementById("employeesAtEnd").value); var employeesHired = parseFloat(document.getElementById("employeesHired").value); var resultDiv = document.getElementById("result"); resultDiv.innerHTML = ""; // Clear previous results if (isNaN(employeesAtStart) || isNaN(employeesAtEnd) || isNaN(employeesHired) || employeesAtStart < 0 || employeesAtEnd < 0 || employeesHired 0 or hires > 0, this scenario is unusual for attrition calculation. // For simplicity and common use cases, we'll assume employeesAtStart > 0 for the average calculation. // A more robust calculation might handle these edge cases differently depending on business context. var averageEmployees = (employeesAtStart + employeesAtEnd) / 2; var attritionRate = 0; if (averageEmployees > 0) { attritionRate = (departures / averageEmployees) * 100; } else if (employeesAtStart === 0 && employeesAtEnd === 0 && employeesHired === 0) { attritionRate = 0; // No employees, no churn. } else { // This case might represent starting with 0 employees and ending with some, or hires without a starting base. // The standard formula's average becomes problematic. // In such specific scenarios, context dictates how to interpret. // For this calculator, we'll indicate an issue or assume 0% if no departures are possible from a zero base. if (departures === 0) { attritionRate = 0; } else { resultDiv.innerHTML = "Cannot calculate average employees for attrition rate with these inputs."; return; } } resultDiv.innerHTML = "Number of Departures: " + departures + "" + "Average Number of Employees: " + averageEmployees.toFixed(2) + "" + "Attrition Rate: " + attritionRate.toFixed(2) + "%"; } .calculator-container { font-family: Arial, sans-serif; border: 1px solid #ccc; padding: 20px; border-radius: 8px; max-width: 500px; margin: 20px auto; background-color: #f9f9f9; } .calculator-inputs { display: grid; grid-template-columns: 1fr; gap: 15px; margin-bottom: 20px; } .input-group { display: flex; flex-direction: column; } .input-group label { margin-bottom: 5px; font-weight: bold; } .input-group input { padding: 8px; border: 1px solid #ccc; border-radius: 4px; box-sizing: border-box; } button { background-color: #4CAF50; color: white; padding: 10px 15px; border: none; border-radius: 4px; cursor: pointer; font-size: 16px; width: 100%; margin-bottom: 15px; } button:hover { background-color: #45a049; } #result { margin-top: 20px; padding: 15px; border: 1px dashed #aaa; border-radius: 4px; background-color: #fff; text-align: center; } #result p { margin: 5px 0; }

Leave a Comment