Employee attrition rate, often referred to as employee turnover, is a crucial metric for understanding the health and stability of a workforce. It measures the percentage of employees who leave an organization over a specific period. A high attrition rate can indicate underlying issues within the company, such as poor management, lack of growth opportunities, inadequate compensation, or a toxic work environment. Conversely, a low attrition rate generally suggests a positive and engaging workplace.
.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-container h2 {
text-align: center;
color: #333;
margin-bottom: 15px;
}
.calculator-container p {
font-size: 0.9em;
color: #555;
line-height: 1.5;
margin-bottom: 25px;
}
.input-section {
margin-bottom: 15px;
}
.input-section label {
display: block;
margin-bottom: 5px;
font-weight: bold;
color: #444;
}
.input-section input[type="number"] {
width: calc(100% – 12px);
padding: 8px;
border: 1px solid #ccc;
border-radius: 4px;
box-sizing: border-box; /* Include padding and border in the element's total width and height */
}
button {
display: block;
width: 100%;
padding: 10px 15px;
background-color: #007bff;
color: white;
border: none;
border-radius: 5px;
cursor: pointer;
font-size: 1.1em;
transition: background-color 0.3s ease;
margin-top: 20px;
}
button:hover {
background-color: #0056b3;
}
.result-section {
margin-top: 20px;
padding: 15px;
background-color: #e9ecef;
border: 1px solid #ced4da;
border-radius: 5px;
text-align: center;
font-size: 1.1em;
font-weight: bold;
color: #333;
}
function calculateAttritionRate() {
var employeesAtStart = parseFloat(document.getElementById("employeesAtStart").value);
var employeesAtEnd = parseFloat(document.getElementById("employeesAtEnd").value);
var employeesWhoLeft = parseFloat(document.getElementById("employeesWhoLeft").value);
var resultDiv = document.getElementById("result");
// Validate inputs
if (isNaN(employeesAtStart) || employeesAtStart < 0) {
resultDiv.textContent = "Please enter a valid number of employees at the start.";
return;
}
if (isNaN(employeesAtEnd) || employeesAtEnd < 0) {
resultDiv.textContent = "Please enter a valid number of employees at the end.";
return;
}
if (isNaN(employeesWhoLeft) || employeesWhoLeft < 0) {
resultDiv.textContent = "Please enter a valid number of employees who left.";
return;
}
// Calculate the average number of employees over the period
var averageEmployees = (employeesAtStart + employeesAtEnd) / 2;
// Handle division by zero if averageEmployees is 0
if (averageEmployees === 0) {
resultDiv.textContent = "Cannot calculate attrition rate: average employees is zero.";
return;
}
// Calculate attrition rate
var attritionRate = (employeesWhoLeft / averageEmployees) * 100;
// Display the result
resultDiv.textContent = "Employee Attrition Rate: " + attritionRate.toFixed(2) + "%";
}