? Study Note Excel & SQL
? Study Note Excel & SQL
Removing Duplicates
Text-to-Columns
Data Validation
Conditional Formatting
Named Ranges
Introduction to DAX
Keyboard Shortcuts
Dynamic Ranges
Handling NULLs
Temporary Tables
Nested Queries
Indexing
Excel is a spreadsheet application developed by Microsoft that allows users to store, organize, and
analyze data using rows and columns. It’s been the OG sidekick of analysts, accountants, and data
nerds for decades.
Ease of Use: Drag, drop, click. You can analyze and visualize without writing a single line
of code.
Versatility: You can do everything from basic budgeting to complex data modeling.
Integrations: Works well with other Microsoft tools and even connects with databases and
APIs via Power Query.
💡 Think of Excel as the Swiss Army knife of data tools—basic enough for daily use, powerful enough
for serious data crunching.
Before we start writing formulas like a mad scientist, let’s look around the lab:
Ribbon: The top menu with tabs like Home, Insert, Formulas, Data, etc. Each tab contains
tools grouped by functionality.
Worksheet Tabs: Each sheet at the bottom is like a new page in your workbook. You can
rename, color-code, and rearrange them.
Columns and Rows: Columns are labeled A-Z, then AA, AB, etc.; rows are numbered. The
intersection is a cell (like B2).
Formula Bar: Where you see or write the formula or value of the selected cell.
Name Box: Shows the cell address or lets you name a range (e.g., SalesData).
Quick Access Toolbar: Customizable mini toolbar for frequently used actions (save, undo,
redo, etc.).
Navigation Tips:
How you structure your data can make or break your analysis. Excel doesn’t judge—but future-you
will.
Do:
Keep one data type per column (e.g., don’t mix dates and text).
Don’t:
Use formatting alone (e.g., colors or bold text) to signify meaning. Use helper columns or
notes.
Hardcode calculations directly into your dataset. Use formulas in separate columns.
Pro Tip: Use Excel Tables (Ctrl + T) to:
Alright! Buckle up, we're diving into the fun zone of formulas—where Excel goes from "digital
notebook" to "data wizard." 🧙♂️
Understanding functions is like learning spells in Hogwarts—each one does something magical to
your data. Here’s a breakdown of the key categories and what each function brings to your analysis
arsenal.
These are your bread-and-butter for crunching numbers and making decisions.
Examples:
➤ IF
Example:
=IF(C2>100, "High", "Low") – Returns “High” if C2 > 100, else “Low”.
Examples:
🧠 These functions let you write “rules” for your data. Super useful in dashboards or cleaning tasks.
🔹 Text Functions
Text data isn’t always clean. These functions help you slice, dice, and fix it.
Examples:
o =LEFT(A1, 3) – Gets the first 3 characters from cell A1.
➤ CONCATENATE / TEXTJOIN
Examples:
o =TEXTJOIN(", ", TRUE, A1:A5) – Joins all non-empty cells with commas.
➤ TEXT
Example:
=TEXT(A1, "MM/DD/YYYY") – Converts a date into a readable format.
➤ TODAY(), NOW()
Examples:
Examples:
Example:
=WEEKDAY(A1) – Tells you which day of the week it is (Sunday = 1).
Use This
Task
Function(s)
Sum or average
SUM, AVERAGE
values
CONCATENATE
TODAY(), DATEDIF,
Work with dates
YEAR
Format numbers or
TEXT, TEXTJOIN
text
Let’s sweep through the data jungle and come out squeaky clean! 🧼
Welcome to Excel’s backstage crew—cleaning the data before it hits the spotlight.
“Garbage in, garbage out” is the golden rule in data analysis. You can’t build solid insights on a
wonky foundation, and this section is all about turning chaos into clarity.
🔹 Removing Duplicates
Sometimes Excel gets a little too enthusiastic and gives you double (or triple) the data. Time to
declutter.
➤ How to:
💡 Pro Tip:
Always keep a backup sheet before removing duplicates. Excel deletes them without mercy.
🔹 Text-to-Columns
Got values crammed into a single column like a data sardine can? Split them up.
➤ Use Case:
A full name like “John Smith” or an address like “New York, NY” in one cell.
➤ How to:
Choose Delimited (for commas, spaces, etc.) or Fixed Width (if spacing is consistent).
➤ How to:
You can even use wildcards like * and ? for advanced searches.
🔹 Data Validation
Keep junk out before it ever enters your clean data sanctuary.
➤ Purpose:
Restrict inputs to valid entries only (e.g., numbers between 1–100, specific categories,
dates only).
➤ How to:
💡 Example:
Blank cells? Missing dates? Incomplete values? Excel has a toolkit for that too.
➤ Common Strategies:
➤ Bonus Tip:
💬 Missing data isn’t scary—it’s just shy. You just need to know how to talk to it.
Messy or inconsistent
Find & Replace
text
Problem Fix It With
Wrong or invalid
Data Validation
entries
IF/ISBLANK/IFERROR
Blank or missing data
formulas
Alright, now that our data is clean and presentable (it's basically ready for a LinkedIn profile pic 😎),
it’s time to analyze the heck out of it!
This is where Excel shows off—transforming rows and columns into insights, patterns, and "a-ha!"
moments.
➤ Sorting
How to:
Select your data → Go to Data tab → Use Sort A-Z, Z-A, or Custom Sort.
You can sort on multiple levels (e.g., sort by Region, then by Sales within each Region).
➤ Filtering
How to:
Go to Data tab → Click Filter.
🧃 Think of filters as the juice extractor—you only keep the good stuff.
🔹 Conditional Formatting
Make important values pop without lifting a finger (okay, maybe one finger).
➤ Use Cases:
Show duplicates
➤ How to:
Choose:
o Color Scales
o Icon Sets
💡 Tip:
🔹 Lookup Functions
Your data has relatives in other sheets? Time for Excel's version of matchmaking.
Classic. Looks up a value in the leftmost column and returns a value in the same row
from a specified column.
➤ INDEX-MATCH Combo
🎯 Lookups are how you "connect the dots" across messy tables.
🔹 Named Ranges
Giving a range a name makes formulas cleaner, readable, and less error-prone.
➤ How to:
Select a range → Click in the Name Box (left of the formula bar) → Type a name like
SalesData
💡 Uses:
Cleaner formulas
Create dynamic
Named Ranges
formulas
Nice! Let’s step into Excel’s command center—where raw data transforms into dashboards and
insights with zero drama.
Pivot Tables are like the Sherlock Holmes of Excel—smart, curious, and always uncovering patterns
you didn’t know existed. Pair them with charts? Now you’ve got storytelling power. 📈
Pivot Tables let you summarize, analyze, explore, and present data in just a few clicks. No
formulas needed!
➤ How to:
💡 Example:
Drag Region to Rows, Product to Columns, and Revenue to Values = Boom! Instant
breakdown.
Tired of dropdown filters? Let your data breathe with visual filters.
➤ Slicers
➤ Timelines
Need to group sales by month or ages into buckets? Excel’s got your back.
➤ Grouping:
Options:
➤ Aggregating:
Okay, tables are nice. But charts tell the story at a glance.
Pie Charts: Show parts of a whole (use sparingly—no one likes a pie chart army)
➤ How to:
Use the Chart Design tab to customize styles, titles, labels, etc.
➤ Pro Tips:
Use sparklines (tiny, in-cell charts) for quick visual cues in tables.
Welcome to the Excel Deep Web—where things get powerful, nerdy, and weirdly fun. You’ve
mastered the basics, now let’s enter the Advanced Excel Dimension 🔮
This is the part where Excel goes from spreadsheet to supercomputer. We’re talking automation,
advanced data modeling, and features that practically run your reports while you nap.
Power Query is like Excel’s data butler—it gets your data, cleans it up, and serves it piping hot
every time.
➤ What It Does:
Import data from Excel files, CSVs, databases, web, and more
➤ How to Use:
🔄 Common Tasks:
Remove columns
Split text
Unpivot columns
Merge tables
Filter rows
🧽 Once set up, you just click “Refresh” and all steps re-run. Excel on autopilot.
➤ How to Use:
Load data via Power Query or directly into the Power Pivot model
💥 Benefits:
Lightning-fast calculations
🧠 You’re not just using Excel now—you’re building a mini database inside Excel.
DAX is Power Pivot’s brain. It’s like Excel formulas... but deeper, smarter, and more expressive.
➤ Example:
excel
CopyEdit
💡 Use Cases:
Excel 365 brought some juicy new features that make formulas explode with efficiency.
➤ New Functions:
➤ Example:
excel
CopyEdit
=UNIQUE(FILTER(A2:A100, B2:B100="Yes"))
🧪 These functions eliminate helper columns and make your formulas tight and powerful.
Heck yes! 💻✨ Time to trade in our spreadsheet cells for some SQL spells. Welcome to…
SQL is the language of data. Not a language—the language. You use it to query, filter, join, and
summon insights from the vast lands of databases.
Let’s first set up your roadmap—the Table of Contents for SQL mastery:
ORDER BY
INNER JOIN
Scalar subqueries
LEAD, LAG
Handling NULLs
Boom! Let’s light the torches and enter the temple of SQL.
Here comes the first chapter of your SQL scroll…
🟥 2.1 Introduction to SQL
✨ “Structured Query Language: The only time it’s OK to yell at a database and expect useful
answers.”
🔹 What is SQL?
SQL (Structured Query Language) is a standardized language used to interact with relational
databases.
Want to know which product sold the most last month? SQL.
SQL is like English: the grammar is mostly the same, but there are accents and slang. Each RDBMS
(Relational Database Management System) has its own "flavor."
WordPress
SQL Microsoft
Friendly with Excel, Power BI
Server ecosystems
Apps, mobile
SQLite File-based, simple, portable
databases
Oracle Enterprise
Complex, very powerful
SQL environments
FROM employees
📌 Key Notes:
Each command ends with a ; (except in some tools that don’t require it)
SQL lets you write comments (which are ignored by the database) to make your queries readable:
🧙 Think of comments as breadcrumbs for your future self or your confused coworkers.
2.2 SELECT Statements & Filtering and start querying like it’s nobody’s business? 🧩
Absolutely! Let’s go full throttle now—examples, analogies, and real-world spice included.
Time to flex some SQL muscles with…
The SELECT statement is your primary weapon in SQL—like a Google search bar for databases.
Filtering? That’s your magnifying glass. 🔍
🧠 Basic Syntax:
FROM table_name
WHERE condition;
FROM employees
FROM employees
💡 Combo Example:
SELECT *
FROM employees
WHERE department = 'Sales' AND salary < 50000;
FROM employees
FROM employees
FROM employees
FROM employees
SELECT first_name
FROM employees
FROM employees
Gets folks without managers—maybe they are the managers. Or just forgot to fill that field.
🔂 Real-World Analogy Time
SQL
Real-Life Equivalent
Concept
"Where no dessert is
IS NULL
selected yet"
Claus
Purpose
e
SELEC
What data to show
T
WHER
Filter it down
E
AND/
Combine filter conditions
OR
IS
Find missing data
NULL
Wanna jump into 2.3 Sorting & Limiting Results next and learn how to cherry-pick the top rows
or order your results like a boss? 📊🍒
Let’s gooo! 🔥 Now that you can find the data, it’s time to sort it, rank it, and grab only what
matters—like a data connoisseur. 🧑🍳
✨ “You can have all the rows you want… but not in that chaotic order.”
🧠 Basic Syntax:
DESC = Descending
FROM employees
FROM employees
FROM employees
SELECT *
FROM employees
LIMIT 5;
Useful for previewing data or testing queries without grabbing the whole galaxy.
SELECT TOP 5 *
FROM employees;
LIMIT 3;
SQL Pro Tip: Always use ORDER BY before LIMIT—otherwise, you’re just grabbing any 3 rows, not
the most relevant ones.
Use this when you're building things like "Page 2" of results.
FROM employees
🧠 Summary Snapshot
ASC /
Sets sort direction
DESC
✨ “When one row just isn’t enough… roll them all up into glorious summaries.”
Aggregate functions calculate a single value from a group of rows—like totals, averages, or
counts. These are crucial for reporting, dashboards, and those sweet one-liner insights.
Functi
What It Does
on
Adds up numeric
SUM()
values
Calculates the
AVG()
average
🧮 Examples of Each:
FROM employees;
FROM employees;
FROM employees;
FROM employees;
FROM employees;
🔹 GROUP BY – The Real MVP
FROM employees
GROUP BY department;
Each group = one department. SQL computes the average for each.
FROM employees
GROUP BY department
🔹 Combo Example: Count employees per department, but only if more than 5 employees
FROM employees
GROUP BY department
🤯 Real-World Analogy
Concep
Like…
t
COUNT( Headcount at a
*) wedding
Clause Purpose
You now have the power to summarize data like a reporting master.
Next up is the lifeblood of all data work—💥 2.5 Joins and Combining Data. Wanna dive in?
🧾 customers
customer nam
_id e
1 Alice
2 Bob
Charli
3
e
📦 orders
101 1 Laptop
102 2 Phone
103 4 Monito
order_ custome produ
id r_id ct
FROM customers
✅ Returns:
nam produ
e ct
Lapto
Alice
p
Bob Phone
Ignores Charlie (no order) and order 103 (no matching customer).
Like inviting only friends who RSVP'd “yes.”
🔸 2. LEFT JOIN – "All from the left, matches from the right"
FROM customers
✅ Returns:
nam produ
e ct
Lapto
Alice
p
Bob Phone
Charli
NULL
e
🔸 3. RIGHT JOIN – "All from the right, matches from the left"
FROM customers
✅ Returns:
nam produ
e ct
Alice Laptop
nam produ
e ct
Bob Phone
NUL Monito
L r
FROM customers
✅ Returns:
nam produ
e ct
Alice Laptop
Bob Phone
Charli
NULL
e
Monito
NULL
r
FROM employees e
This links each employee to their manager by joining the table to itself.
FROM customers a
Multiplies every row in one table with every row in the other.
Alice gets all products. Bob gets all products. Madness ensues. 😵
🧠 Summary Table
JOIN Type What It Does
You're now officially a Data Alchemist—turning scattered tables into golden insights. 🧪✨
Ready to dive into 2.6 Subqueries and CTEs? Think SQL inside SQL—Inception, but for analysts.
Oh yesss! 🌀 Welcome to SQL Inception: Queries within queries—where things get a little meta and
a lot powerful. 😎
This is where the pros hang out. Let’s lift the hood.
Both subqueries and CTEs help you build complex logic step-by-step, keeping your main query
clean and readable.
FROM employees
SELECT AVG(salary)
FROM employees
);
That inner query (SELECT AVG(salary)) runs first, then the outer query uses its result.
🔸 Types of Subqueries:
FROM employees;
B. Table Subquery – Returns a table-like result
SELECT *
FROM (
) AS sales_employees;
FROM employees e1
SELECT AVG(e2.salary)
FROM employees e2
);
Compares each employee’s salary to the average of their department. Think of it as a row-by-row
comparison.
💡 Use WITH to define a temporary result set that you can refer to later in your query. Great for
clean, readable logic.
📌 Syntax:
WITH temp_table AS (
FROM employees
GROUP BY department
SELECT *
FROM temp_table
WITH ranked_employees AS (
FROM employees
SELECT *
FROM ranked_employees
WHERE rank = 1;
Go
Use Case
With...
Subquer
One-off logic, simple filter
y
Complex ranking /
CTE
partitioning
🎯 Real-Life Analogy
SQL
Feels Like…
Feature
🔍 TL;DR Summary
This part is all about designing strong tables: choosing the correct data types, applying the
right constraints, and avoiding future chaos.
📌 Example:
name VARCHAR(100),
price DECIMAL(10,2),
available BOOLEAN,
);
🧷 Key Types:
Constrain
What It Does
t
No duplicate values in a
UNIQUE
column
department_id INT,
);
Enforces:
Unique email ✅
No null names ✅
Positive salary ✅
Valid department ID ✅
🔑 PRIMARY KEY
🔗 FOREIGN KEY
Principle Explanation
Normalize your
Split into logical, related tables
tables
Index key
Speeds up search & joins
columns
🧠 Real-World Analogy
SQL
Real Life Equivalent
Concept
use
Primary
File ID on a folder
key
Cross-reference to
Foreign key
another file
customer_name TEXT,
product_id TEXT,
sale_date VARCHAR(10),
price TEXT
);
🛑 Problems:
No keys = no structure
No constraints = no guardrails
➡️This is a recipe for a data disaster!
🎯 TL;DR Summary
🔥 Final stretch: Want to move on to Part 3: Real-World Projects and Case Studies next?
Let’s gooo! 🏁
You've mastered the tools. Now it's time to use them in battle. ⚔️
Welcome to…
✨ “Theory is nice, but can it handle messy real-world data at 3AM before a deadline?”
This section puts your SQL + Excel powers to the test in practical, project-style scenarios, just
like what you’d see in analytics jobs or freelance gigs.
✅ Problem Statement
🧠 Step-by-step solutions
So, wanna start with 3.1 E-Commerce Sales Dashboard and build it like a real analyst?
Ohhh yes! 🛒💸 Let’s build that E-Commerce Sales Dashboard like a data-driven beast.
This is classic territory: orders, customers, revenue, and insights that make stakeholders say
“Wait… you did this in Excel and SQL?”
✅ Problem Statement:
“We want to understand sales performance by month, region, and product category. Also, which
customers are buying the most, and which products are underperforming?”
📦 Dataset Structure
🧾 customers
1 Alice North
2 Bob West
3 Charli Sout
customer nam regi
_id e on
e h
📦 orders
2024-11-
101 1 2500
01
2024-11-
102 2 1800
05
2024-11-
103 1 900
07
order_items
Electroni 250
1 101 Laptop 1
cs 0
Smartphon Electroni
2 102 2 900
e cs
Accessori
3 103 Mouse 3 300
es
🔧 Tools Breakdown
Task Tool
Data cleaning,
Excel
dashboard build
🧠 Step-by-Step Breakdown
Remove duplicates
SELECT
FROM orders
GROUP BY order_month
ORDER BY order_month;
🎯 Output:
order_mo monthly_rev
nth enue
2024-11 5200
FROM customers c
GROUP BY c.name
LIMIT 5;
FROM customers c
GROUP BY c.region
FROM order_items
GROUP BY category
FROM order_items
GROUP BY product_name
➡️Flag these in Excel with conditional formatting (maybe red text? 🚨).
Dynamic date
Timeline + PivotTable
slicer
SUMIFS, COUNTIFS,
KPI summary
AVERAGEIF
Region-wise
Slicers
buttons
Add a title, logos, filters, and boom—you’ve got yourself a client-ready dashboard. 🎨📊
✅ Problem Statement:
“We need a dashboard that tracks employee performance, attrition trends, and salary distribution.
Also, identify top performers and departments with high turnover.”
Get ready to flex with Excel AND SQL on a people-powered mission! 🧑💼⚙️
📦 Dataset Structure
👥 employees
employe nam departm join_dat sala
status
e_id e ent e ry
2022-01- 6500
1 Alice Sales Active
15 0
📈 performance_reviews
2023-12-
101 1 4.5
01
2023-12-
102 2 3.2
01
2023-12-
103 3 4.8
01
🧠 Step-by-Step Breakdown
FROM employees
GROUP BY department
FROM employees e
SELECT
department,
COUNT(*) AS attrition_rate
FROM employees
GROUP BY department;
0–1 yrs
1–3 yrs
3–5 yrs
5+ yrs
=IFS(
TRUE, "High"
FROM employees e
Y-axis: Salary
➡️See if higher performers are paid fairly 👀
🧰 Bonus Excel Formulas
Goal Formula
Count of resigned
=COUNTIF(status_range, "Resigned")
employees
Avg Salary by
Bar Chart
Dept
Conditional Format
Attrition by Dept
Table
Performance
Ranked Table
Leaders
Tenure
Histogram
Distribution
Department
Status
Year of joining
With this dashboard, you can walk into any HR meeting and drop insights like a mic 🎤
Wanna keep the train rolling into 3.3: Marketing Campaign Performance?
Boom! 💣 Time to hit the marketing team with data so good, it’ll make their click-through rates
jealous.
Welcome to…
“We ran campaigns across channels—emails, ads, social media—but we don’t know which ones
worked. Help us figure it out.”
And expose which campaigns are heroes… and which are just burning money. 🔥
📦 Dataset Overview
📣 campaigns
2024-03- 2024-03-
1 Spring Sale Email 5000
01 31
📊 campaign_results
120
101 1 10000 150 7500
0
220
102 2 25000 300 14500
0
🧠 Step-by-Step Analysis
SELECT
c.name,
c.channel,
r.impressions,
r.clicks,
r.conversions,
r.revenue,
c.budget,
FROM campaigns c
Conversion Rate
Net Profit
SELECT
name,
FROM campaigns c
SELECT name,
CASE
ELSE 'Ended'
END AS status
FROM campaigns;
Channel-wise status
In Excel:
📋 ab_tests
test_ varia impressi clic conversi
id nt ons ks ons
1 A 5000 800 90
100
2 B 5000 130
0
Calculate:
In Excel:
=clicks / impressions
=conversions / clicks
Component Visual
Campaign ROI
Bar chart
leaderboard
A/B Testing
Bar chart or table
Comparison
Add interactivity:
Channel filter
🧠 Extra Thoughts
Boom! 💣 Time to hit the marketing team with data so good, it’ll make their click-through rates
jealous.
Welcome to…
🟨 3.3 Marketing Campaign Performance Analysis
“We ran campaigns across channels—emails, ads, social media—but we don’t know which ones
worked. Help us figure it out.”
And expose which campaigns are heroes… and which are just burning money. 🔥
📦 Dataset Overview
📣 campaigns
2024-03- 2024-03-
1 Spring Sale Email 5000
01 31
📊 campaign_results
120
101 1 10000 150 7500
0
220
102 2 25000 300 14500
0
🧠 Step-by-Step Analysis
SELECT
c.name,
c.channel,
r.impressions,
r.clicks,
r.conversions,
r.revenue,
c.budget,
FROM campaigns c
Conversion Rate
Net Profit
SELECT
name,
FROM campaigns c
SELECT name,
CASE
ELSE 'Ended'
END AS status
FROM campaigns;
Channel-wise status
In Excel:
📋 ab_tests
1 A 5000 800 90
100
2 B 5000 130
0
Calculate:
In Excel:
=clicks / impressions
=conversions / clicks
Component Visual
Campaign ROI
Bar chart
leaderboard
A/B Testing
Bar chart or table
Comparison
Add interactivity:
Channel filter
🧠 Extra Thoughts
🔢 Excel Fundamentals
🧠 SQL Fundamentals
3.2 HR Analytics
This is where Excel and SQL say: “I may look simple, but I’m conditionally powerful.” 💪
Operatio
Excel SQL
n
=AND(A2>10,
AND WHERE A > 10 AND B = 'Yes'
B2="Yes")
Operatio
Excel SQL
n
=OR(A2="X",
OR WHERE A = 'X' OR B = 'Y'
B2="Y")
Greater
=A2>100 WHERE A > 100
Than
✅ IF with AND/OR
✅ Nested IFs
✅ NOT Operator
✅ CASE Logic
SELECT
name,
salary,
CASE
END AS salary_band
FROM employees;
SELECT *,
CASE
ELSE 'Sufficient'
END AS stock_status
FROM inventory;
=IF(score>4.5, "Top", CASE WHEN score > 4.5 THEN 'Top' ELSE
Flag high performers
"Average") 'Average' END
=IF(ISBLANK(C2), "Missing",
Check missing value WHERE column IS NULL
"OK")
Conditional =IF(A2>500, "Premium", CASE WHEN A > 500 THEN 'Premium' ELSE
categorization "Standard") 'Standard'
Multi-level
Nested IF() or IFS() Multiple WHEN in CASE
classification
Try creating Boolean filters to power dashboards (like TRUE/FALSE flags for slicers)
🎓 Final Words
You’ve mastered:
Next step? Start building real projects. Or integrate Power BI, Python, or Tableau into this workflow
for even more firepower. 🔥
Need flashcards? Mini quizzes? Case study ideas? Just say the word and we’ll keep building.