Skip to content

About

Analyzed employee attrition and workforce data using sql and power bi to identify hr trends and retention risk factors.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

14 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 

Repository files navigation

👥 HR Analytics — Employee Attrition Dashboard

SQL Server PowerBI Dataset Status

🎯 Project Overview

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?


📁 Repository Structure

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

🛠️ Tools & Technologies

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

📦 Dataset

  • Source: IBM HR Analytics Employee Attrition Dataset (Kaggle)
  • Size: 1,470 employees | 35 features
  • Key columns: Age, Department, JobRole, MonthlyIncome, Attrition, JobSatisfaction, YearsAtCompany

🔄 Project Workflow

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

🔍 Key Findings

Overall KPIs

Metric Value
Total Employees 1,470
Employees Who Left 237
Attrition Rate 16.12%
Avg Monthly Income $6,502

Finding 1 — Sales Department Has Highest Attrition

Department Attrition Rate
Sales 20.63% ⚠️
Human Resources 19.05% ⚠️
Research & Development 13.84%

→ Sales loses 1 in 5 employees — the highest risk department

Finding 2 — Young Employees Leave the Most

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

Finding 3 — Low Job Satisfaction = High Attrition

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

Finding 4 — Managers Earn 5x More Than Entry Level

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

Finding 5 — Gender Distribution

  • Male: 882 employees (60%)
  • Female: 588 employees (40%)

💡 Business Recommendations

# 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

📊 SQL Highlights

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

📈 Dashboard Preview

HR Analytics Dashboard

Dashboard Features

  • 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

▶️ How to Run This Project

  1. Clone this repository
git clone https://github.com/Devendra0602/HR-Analytics-SQL-PowerBI.git
  1. Open SQL Server Management Studio (SSMS)

  2. Run sql/hr_analysis.sql to create the database, table, and views

  3. Import the IBM HR dataset into the HR_Employees table

  4. Open powerbi/HR_Analytics_Dashboard.pbix in Power BI Desktop

  5. Update the data source connection to your SQL Server instance


👤 Author

Devendra Patil


📌 Resume Line for This Project

"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"

About

Analyzed employee attrition and workforce data using sql and power bi to identify hr trends and retention risk factors.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors