HR Attrition Analysis Using SQL & Tableau
HR Attrition Analysis Using SQL & Tableau
Project Overview
This project leverages SQL and Tableau to analyze employee attrition. The data is structured into two tables: Employees
and Attrition. SQL queries facilitate data retrieval, while Tableau is used for visualization. The project and SQL queries
were developed with the assistance of ChatGPT, an AI-powered tool, ensuring ethical AI utilization for data analysis and
insights..
1. Database Schema
To analyze attrition in the company, we modify the existing Employees table and introduce an Attrition table.
first_name VARCHAR(50),
last_name VARCHAR(50),
department VARCHAR(50),
hire_date DATE,
salary DECIMAL(10,2)
);
employee_id INT,
attrition_date DATE,
reason VARCHAR(100),
);
2. Sample Data
Employees Data
VALUES
Attrition Data
VALUES
FROM Employees e
SELECT e.department,
COUNT(a.attrition_id) AS total_attrition,
COUNT(e.employee_id) AS total_employees,
FROM Employees e
GROUP BY e.department;
FROM Employees e
LIMIT 3;
4. SQL Testing
The SQL queries were tested and verified using DB Fiddle to ensure accuracy.
HR Attrition Analysis in Tableau
The data was imported into Tableau Public, and the following visualization was created using a Highlight Table.
Visualization Details
Filters: Department
The Highlight Table effectively represents employee attrition trends along with their salary data over the years.
1. Project Overview
Employee attrition is a crucial factor that impacts an organization’s workforce planning and performance. This project
aims to analyze attrition patterns using Tableau to derive insights on employee turnover, salary impact, and department-
wise attrition trends. The project and SQL queries used for data preparation were referred from ChatGPT.
2. Data Preparation
The dataset used for this analysis includes the following key attributes:
First Name & Last Name – Employee details (not used in visualization)
Reason – Reason for attrition (not visualized but useful for deep-dive analysis)
Data was cleaned and formatted in Tableau, ensuring correct data types and calculated fields where necessary.
To create a calculated field that checks whether an employee exists in another sheet, follow these steps:
o In the Data Pane (left side), click the small ▼ dropdown arrow next to Sheet1.
o This checks whether an employee exists in Sheet2. If not, it returns "No"; otherwise, "Yes".
3. Key Visualizations
Columns: Department
Insight: The bar chart visually represents the attrition distribution across departments.
Insight: Shows attrition patterns over time, identifying peak turnover periods.
Columns: Salary
Marks: Square
Insight: Shows a heatmap-style representation of salary distribution across different attrition categories and hire
years.
High Attrition in Certain Departments: Some departments exhibit higher attrition rates than others.
Salary Influence on Attrition: Employees with lower salaries appear more likely to leave.
Year-wise Trends: Certain years show higher turnover, possibly due to external factors like company policies, market
trends, or economic conditions.
click here to view: HR Attrition Analysis in Tableau
5. Conclusion
This HR Attrition Analysis using Tableau provides valuable insights into employee retention and salary impact. The
visualizations help HR teams identify patterns, strategize retention policies, and address key attrition factors. Further
analysis can include reasons for attrition, job roles, and performance ratings to refine insights