A company is losing employees and wants to understand who is leaving, which departments are most affected, and what factors drive attrition. This project performs end-to-end HR data analysis using SQL Server and Power BI to identify attrition patterns and provide workforce retention recommendations.
Business Problem: 16.12% of employees are leaving — that's 1 in 6 people. Which departments and age groups are most at risk, and what can HR do about it?
HR-Analytics-SQL-PowerBI/
│
├── sql/
│ └── hr_analysis.sql # All SQL queries, views & KPI calculations
│
├── powerbi/
│ └── HR_Analytics_Dashboard.pbix # Interactive Power BI dashboard
│
├── images/
│ └── dashboard.png # Dashboard screenshot
│
└── README.md
| Tool | Purpose |
|---|---|
| SQL Server | Data storage, exploration, transformation & KPI calculation |
| SQL Views | Created reusable views connected directly to Power BI |
| Power BI | Interactive dashboard with filters and visuals |
| IBM HR Analytics Dataset | 1,470 employee records with 35 attributes |
- Source: IBM HR Analytics Employee Attrition Dataset (Kaggle)
- Size: 1,470 employees | 35 features
- Key columns: Age, Department, JobRole, MonthlyIncome, Attrition, JobSatisfaction, YearsAtCompany
Step 1 → Imported IBM HR dataset into SQL Server
↓
Step 2 → Data Exploration (row counts, basic checks)
↓
Step 3 → Created derived columns in SQL
(Age Groups, Attrition Flag 0/1)
↓
Step 4 → Built SQL Views for KPIs
(vw_HR_Base, vw_HR_KPIs, vw_Attrition_By_Department, vw_AgeGroup_Attrition)
↓
Step 5 → Connected Power BI directly to SQL Server views
↓
Step 6 → Built interactive dashboard with 8 visuals + department filter
| Metric | Value |
|---|---|
| Total Employees | 1,470 |
| Employees Who Left | 237 |
| Attrition Rate | 16.12% |
| Avg Monthly Income | $6,502 |
| Department | Attrition Rate |
|---|---|
| Sales | 20.63% |
| Human Resources | 19.05% |
| Research & Development | 13.84% |
→ Sales loses 1 in 5 employees — the highest risk department
| Age Group | Total | Left |
|---|---|---|
| Under 25 | 97 | 38 |
| 25–34 | 554 | 112 |
| 35–44 | 505 | 51 |
| 45–54 | 245 | 25 |
| 55+ | 69 | 11 |
→ Employees under 34 account for the majority of attrition — early career retention is critical
| Satisfaction Level | % Who Stayed |
|---|---|
| Level 4 (Highest) | 88.67% |
| Level 3 | 83.48% |
| Level 2 | 83.57% |
| Level 1 (Lowest) | 77.16% |
→ Employees with lowest job satisfaction churn at 22.84% — nearly double the company average
| Job Role | Avg Monthly Income |
|---|---|
| Manager | $17,200 |
| Research Director | $16,000 |
| Research Scientist | $3,200 |
| Human Resources | $4,200 |
→ Large income gap between roles may contribute to dissatisfaction and attrition in lower-paid roles
- Male: 882 employees (60%)
- Female: 588 employees (40%)
| # | Recommendation | Target |
|---|---|---|
| 1 | Launch retention program for Sales department | Sales team (20.63% attrition) |
| 2 | Create career growth paths for employees under 34 | Young workforce |
| 3 | Conduct job satisfaction surveys and act on Level 1 feedback | Low satisfaction employees |
| 4 | Review compensation structure for Research Scientists and HR roles | Lower-paid roles |
| 5 | Introduce mentorship programs to improve early-career retention | Under 25 age group |
The project uses SQL Views connected directly to Power BI — the same approach used in real industry workflows:
-- KPI View used in Power BI dashboard
CREATE VIEW vw_HR_KPIs AS
SELECT
COUNT(*) AS Total_Employees,
SUM(Attrition_Flag) AS Attrition_Count,
CAST(SUM(Attrition_Flag) * 1.0 / COUNT(*) AS DECIMAL(6,4)) AS Attrition_Rate,
CAST(AVG(MonthlyIncome) AS INT) AS Avg_Monthly_Income
FROM vw_HR_Base;-- Age Group bucketing using CASE statement
CASE
WHEN Age < 25 THEN 'Under 25'
WHEN Age < 35 THEN '25-34'
WHEN Age < 45 THEN '35-44'
WHEN Age < 55 THEN '45-54'
ELSE '55+'
END AS Age_Group- Department filter (Human Resources / Research & Dev / Sales)
- 4 KPI cards — Total Employees, Attrition Count, Avg Income, Attrition Rate
- Employee by Gender donut chart
- Avg Monthly Income by Job Role bar chart
- Employee Distribution by Attrition donut chart
- Employees by Age Group and Attrition clustered bar chart
- Avg Monthly Income by Department and Attrition
- Attrition Rate by Department
- Attrition by Job Satisfaction Level stacked bar chart
- Clone this repository
git clone https://github.com/Devendra0602/HR-Analytics-SQL-PowerBI.git-
Open SQL Server Management Studio (SSMS)
-
Run
sql/hr_analysis.sqlto create the database, table, and views -
Import the IBM HR dataset into the
HR_Employeestable -
Open
powerbi/HR_Analytics_Dashboard.pbixin Power BI Desktop -
Update the data source connection to your SQL Server instance
Devendra Patil
- 📧 [patildevendra062@gmail.com]
- 💼 [https://www.linkedin.com/in/patil-devendra2701/]
- 🐙 github.com/Devendra0602
"Analyzed IBM HR dataset of 1,470 employees using SQL Server & Power BI — identified Sales department with 20.63% attrition rate and low job satisfaction employees churning at 22.84%, with 5 targeted retention recommendations"
